You are on page 1of 2

>>> a=[10,220,10,"pes",20.

365,'e']
>>> a
[10, 220, 10, 'pes', 20.365, 'e']
>>> b=[]
>>> b
[]
>>> c=list()
>>> c
[]
>>> for i in a:
... print(i)
...
10
220
10
pes
20.365
e
note:list is a func n is possible
>>> for i in a:
... print(a)
...
[10, 220, 10, 'pes', 20.365, 'e']
[10, 220, 10, 'pes', 20.365, 'e']
[10, 220, 10, 'pes', 20.365, 'e']
[10, 220, 10, 'pes', 20.365, 'e']
[10, 220, 10, 'pes', 20.365, 'e']
[10, 220, 10, 'pes', 20.365, 'e']
>>> b=[10,20,30]
>>> c=[40,10,50]
>>> b+c
[10, 20, 30, 40, 10, 50]
>>> d=b+c
>>> d
[10, 20, 30, 40, 10, 50]
>>> e=3
>>> b
[10, 20, 30]
>>> b*e
[10, 20, 30, 10, 20, 30, 10, 20, 30]
>>> list=list()
>>> list
[]
>>> a=[]
>>> a
[]
>>> a.append(20)
>>> a
[20]
>>> a.append(10)
>>> a
[20, 10]
>>> a.append(20,30,40)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list.append() takes exactly one argument (3 given)
See here it shows error
>>> a.extend([30.5,56,99])
>>> a
[20, 10, 30.5, 56, 99]
>>> a.extend(999)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
See now if u still want to insert 999 using extend thn create list using bracket
>>> a.extend([999])
>>> a
[20, 10, 30.5, 56, 99, 999]
>>> a.extend(999)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
>>> a.extend([999])
>>> a
[20, 10, 30.5, 56, 99, 999]
>>> a.extend[(999)]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'builtin_function_or_method' object is not subscriptable
>>> b.pop()
30
>>> b=(5,10,15,20,35,30,40)
>>> b
(5, 10, 15, 20, 35, 30, 40)
>>> b.pop()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'pop'
>>> b=([5,10,15,20,35,30,40])
>>> b
[5, 10, 15, 20, 35, 30, 40]
>>> b.pop()
40
>>> b.pop(0)
5
>>> b
[10, 15, 20, 35, 30]
>>> b.remove(10)
>>> b
[15, 20, 35, 30]
>>> b.remove(15,20)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list.remove() takes exactly one argument (2 given)
>>> b.remove([15,20])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: list.remove(x): x not in list

You might also like