What is List.append() in Python?

The append(elmnt) method is used to add an element at the end of a list.

Syntax


list.append(elmnt)

Parameters

For a parameter, append() requires an element of any type such as a string, number, object, etc.

Code

The following code shows how to use the append() method:

fruits = ["apple", "banana", "Mango"]
shapes = ["Circle", "Triangle", "Square", "Rectangle"]
# Adds both list and print it
print(fruits.append(shapes))
print('Current Fruits List:', fruits)
# Adding element at the end of list Fruits
fruits.append("Pawpaw") # Using the append() function
print('Updated Fruits List:', fruits)

Free Resources