1 dimensional list
a = list()
a.append('books')
a.append('pens')
print(a)
prints,
$ C:/python/Python311/python.exe "c:/Users/LENOVO/OneDrive/Desktop/python/python folder/hello.py" ['books', 'pens']
values = [1, 4, 6, 7, 0]
del values[1]
print(values)
removes 4 from the list,
[1, 6, 7, 0]
values = [1, 4, 6, 7, 0]
del values[1]
values.append('apple')
print(values)
prints,
[1, 6, 7, 0, 'apple']
values = [1, 4, 6, 7, 0]
del values[1]
values.append('apple')
print(values[2:])
it prints the list from 2: ,
[7, 0, 'apple']
2 dimensional list
values = [['apple', 'banana', 'grapes'], [1, 2, 3], ['carrot', 'cabbage', 'beetroot']]
print(values [0][1]) #print in the 1st list to the 2nd value