Working with python means basic three operations on lists i.e. appending, updating and deleting elements in list.
Appending elements to a list:-
It means adding elements at the end of the list. We can do this with the help of a function append().
a=[10, 12, 22, 26] a.append(30) print(a)
Updating elements to a list:-
To update or change an element in a list in place, we have to assign new value to the element’s index in the list.
a=[10, 12, 16, 20, 24] a=18 print(a)
Output- [10, 12, 18, 20, 24]
Deleting elements from a list:-
For deleting elements from a list we use del() function in python. We write the index of the element we have to delete in bracket and then delete it.
a=[1, 2, 3, 4, 5, 6] del a print(a)
Output- [1, 2, 3, 5, 6]
This is all about working with lists in python.