We can create a nested list, like a tuple or dictionary, inside the list, l=[1, 2, 3, [3, 4, 5]]. There are 4 elements and 3 indexes here; 3, 4, and 5 are present in the third index, which is inside the list, so print(l[3][1].
l = [1, 2, 3, ["hello", 3, 4], 5] # it is mixed list
print(l[3][1])
print(l[0:4]) # it is slicing of the list, note (slicing is as same as in string) here 1 less than 4 i.e. 3 so up-to 3 index will be printed
print(l[0::2]) # : sapce : so, this space is used to print all elements and 2 is increment value
print(l[-1::-1]) # it will print reverse elements, starting from -1 and space is to print all element
# and -1 is the decrement value so it wil print index value -1 than -2 than -3 and so on...
l = [2, 3, 4, 4]
for n in range(le):
print(l[n])
for a in l: # this is second method to print iteration, the element of l will be passed in a, and it will be printed
print(a)
for n in range(le):
print(l[n])
for a in l: # this is second method to print iteration, the element of l will be passed in a, and it will be printed
print(a)
for n in range(le - 1, -1, -1): # list will be started from le-1 index
# and will be printed till -1 that is till 0 index and last -1 is
# decrement value. Note: as same as string reverse.
print(n)
l= [1,2,3,4]
del l[2] # it will delete the element which is present in index 2
print(l)
l.pop(1) # if we will print it will show
print(l.pop(0))
print(l)
l.remove(3)
print(l)
l.clear()
print(l)
l=[2,5,68,]
l[0]=90 #it will update the value of index 0
print(l)