How to add elements to list in Python
To insert a new element into a Python list, you can use the append method.
The append method adds the new element to the end of the list.
- The namelist argument is the name of the list.
- The item argument is the value to be added to the list. It can be numeric or alphanumeric.
Note. The new element is added after the last element of the list.
A practical example
Create an empty list.
The list is called city.
Add an element in the list with the method append.
Add another item at the end of the list.
View the contents of the list
['New York', 'Rome']
There are two elements in the list.
Report us an error or send a suggestion to improve this page