๐Ÿ“– Beginning Python Programming /
Module: List & Collection

list & tuple

๐Ÿ“– Beginning Python Programming / List & Collection / list & tuple

List & Tuple

>>> []
[]
>>> [1,2,3,4,5]
[1, 2, 3, 4, 5]
>>> ['Thomas', 'Steven', 'Tom','Susan']
['Thomas', 'Steven', 'Tom', 'Susan']
>>> names = ['Thomas', 'Steven', 'Tom','Susan']
>>> names[-1]
'Susan'
>>> names.append("John")
>>> names
['Thomas', 'Steven', 'Tom', 'Susan', 'John']
>>> names.insert(0,"Peter")
>>> names
['Peter', 'Thomas', 'Steven', 'Tom', 'Susan', 'John']
>>> names = []
>>> names.append("Thomas")
>>> names.append("Tom")
>>> names
['Thomas', 'Tom']
>>> names.insert(1, "Terry")
>>> names
['Thomas', 'Terry', 'Tom']
>>>