Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

>>> list=["eng","math","physics","chem"]

>>> list.append("RAGHAV")

>>> print(list)

['eng', 'math', 'physics', 'chem', 'RAGHAV']

>>> list.sort()

>>> print(list)

['RAGHAV', 'chem', 'eng', 'math', 'physics']

>>> list.count()

Traceback (most recent call last):

File "<pyshell#19>", line 1, in <module>

list.count()

TypeError: count() takes exactly one argument (0 given)

>>> list.count

<built-in method count of list object at 0x020DFB08>

>>> print(list)]

SyntaxError: unmatched ']'

>>> print(list)

['RAGHAV', 'chem', 'eng', 'math', 'physics']

>>> list.pop(0)

'RAGHAV'

>>> print(list)

['chem', 'eng', 'math', 'physics']

>>> #raghav is removed now from the list

>>> print(len(list))

4
]

>>> #print(len(list)) gives number of elements in list

>>> list.append("math")

>>> list.append("math")

>>> list.append("math")

>>> print(list)

['chem', 'eng', 'math', 'physics', 'math', 'math', 'math']

>>> list.sort()

>>> print(list)

['chem', 'eng', 'math', 'math', 'math', 'math', 'physics']

>>> list.count(math)

Traceback (most recent call last):

File "<pyshell#34>", line 1, in <module>

list.count(math)

NameError: name 'math' is not defined

>>> list.count("math")

Basic theory abt list

list=["math","phy","chem","ENg"]

list.append("history")

print(list)

print(list[0])

# writing index in sq brackets like this shows data at a particular position


print(list[-1])

list.insert(1,"CS")

print(list)

list.sort

You might also like