Python List append() Method
Adds an item to the end of the list.
Syntax
Python
Copy Code
list.append(item)
Parameters
Parameter | Description |
---|---|
item |
Required. The item to append to the end of the list. It can be of any type. |
Example
Python
Copy Code
groceries = ['apples', 'oranges', 'paper towels'] groceries.append("tomato soup") print(groceries)
Output
['apples', 'oranges', 'paper towels', 'tomato soup']