How to use append in python?
In python append() function is used to add the element in the list. It just adds the element to end and increase the size of the list by 1.
syntax:-
list.append(item_name)
e.g.,
l=[1, 2, 3, 4, 5] l.append(6) print(l)
We can add a list to a list with the help of append() function.
e.g.,
a=[1, 3, 5, 7, 9] b=[2, 4, 6, 8] a.append(b) print(a)
This is how we can use append in python.
Subscribe
Login
Please login to comment
0 Discussion