Given a list of the elements and we have to add/remove elements in/from the list in Python.
Python List append() Method
It is used to add/append an object (which will be passed in method as parameter) to the list.
Syntax:
list.append(element)
Here,
- list - is the name of the list.
- append() - is the method name, that is used to add element/object to the list.
- element - is an element (which is considered as on object or element) to be added in the list.
Python List pop() Method
It is used to remove/pop an object from the list.
Syntax:
list.pop()
Here,
- list is the name of the list.
- pop() is the method name that is used to remove last element from the list.
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer