





Please login
Prime

Prepinsta Prime
Video courses for company/skill based Preparation
(Check all courses)
Get Prime Video
Prime

Prepinsta Prime
Purchase mock tests for company/skill building
(Check all mocks)
Get Prime mock
Append () in Python
Append() in Python :
Append is used to add element at the end of list. Element can be anything a number , string , another list etc.
Example :
- li=[1, 2 , 4 ]
- li.append( 5)
- li=[ 1 , 2 , 4 , 5 ]
Append does not return any value.

Syntax :
# Adds an object (a number, a string or a another list) at the end of list list_name.append(object)
Code #1:
#pyhton program
#Append
li=[1,2,3]
#add a number
li.append(5)
print(li)
#add a string
li.append(‘PrepInsta’)
print(li)
#add a list at end of the list
ext=[5, 6 , 7]
li.append(ext)
print(li)
Output :
[1, 2, 3, 5]
[1, 2, 3, 5, 'PrepInsta']
[1, 2, 3, 5, 'PrepInsta', [5, 6, 7]]
Login/Signup to comment