In [2]:
list1 = []
print list1
In [4]:
list2 = [10, 3, 4, 2]
print list2
In [5]:
list3 = ['apple', 10, 2.3, [1, 2]]
print list3
In [6]:
list1.append(5)
print list1
list1.append(3)
print list1
list1.append(8)
print list1
In [7]:
print list2
In [8]:
print list2[0]
print list2[1]
print list2[2]
print list2[3]
In [9]:
print list2
In [10]:
print list2[-1]
print list2[-2]
In [11]:
print list2
In [13]:
list2.pop(1) # Should remove value 3
Out[13]:
In [14]:
print list2
There is also a method remove which removes the first item with a given value in the list
In [15]:
list2.remove(4)
print list2
In [18]:
print list2
print len(list2)
In [19]:
print list3
In [20]:
'apple' in list3
Out[20]:
In [21]:
'orange' in list3
Out[21]:
In [ ]: