Python List append() Method
The Python List append() method is used for appending and adding elements to the end of the List.
Syntax: list.append(item)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Parameters:
- item: an item to be added at the end of the list
Returns:
The method doesn’t return any value
Example 1: Adding an Item to the List
Python
# my_listmy_list = ['geeks', 'for'] # Add 'geeks' to the listmy_list.append('geeks') print my_list |
Output:
['geeks', 'for', 'geeks']
Example 2: Adding List to the List
Python
# my_listmy_list = ['geeks', 'for', 'geeks'] # another listanother_list = [6, 0, 4, 1] # append another_list to my_listmy_list.append(another_list) print my_list |
Output:
['geeks', 'for', 'geeks', [6, 0, 4, 1]]
Note: A list is an object. If you append another list onto a list, the parameter list will be a single object at the end of the list.


