Python List append method with Example – Python Tutorial

1 year ago Lalit Bhagtani 0

In this tutorial, we will learn about python list append method.
Python List Append

append method :

This method is used to add an element ( item ) to the end of the list.

Syntax : < List Object >.append( item ) 


[datacamp_exercise lang=”python” height=”350″ min-height=”200″ max-height=”500″]

# create list object and assign it to variable l
l = [‘a’,’b’,’c’,’d’,’e’]

# call append() method by passing ‘f’ as an argument

# print the list, to check its elements

# another way of appending element in the list (without using append() method)
l[len(l):len(l)] = ‘g’

# print the list, to check its elements


References :-

  1. append method Docs

That’s all for Python List append method. If you liked it, please share your thoughts in comments section and share it with others too.