Home » Python

Python List | append() Method with Example

Python List append() Method with Example: In this article, we are going to learn about list.python() Method with Example.
Submitted by IncludeHelp, on August 14, 2018

list.append() Method

append() is an inbuilt method in Python, which is used to add an element/item to the list. append() adds the element at the end.




  • list is the name of the list.
  • element is an item/element to be appended.

Return type: Method append() does not return any value, it just modifies the existing list.


# Python program to demonstrate
# an example of list.append() method 

# list
cities = ['New Delhi', 'Mumbai']

# print the list
print "cities are: ",cities

# append two more cities

# print the updated list
print "cities are:",cities


    cities are:  ['New Delhi', 'Mumbai']
    cities are: ['New Delhi', 'Mumbai', 'Bangalore', 'Chennai']


  • Initially there were two elements in the list ['New Delhi', 'Mumbai']
  • Then, we added two more city names (two more elements) - 1) 'Bangalore' and 2) 'Chennai', by using following python statements:
  •     cities.append('Bangalore');
  • 'Bangalore' and the 'Chennai' will be added at the end of the list named cities.
  • Then, we printed the updated list; the output will be a new list with 4 elements ['New Delhi', 'Mumbai', 'Bangalore', 'Chennai'].

Comments and Discussions

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.