The append(elmnt)
method is used to add an element at the end of a list.
list.append(elmnt)
For a parameter, append()
requires an element of any type such as a string, number, object, etc.
The following code shows how to use the append()
method:
fruits = ["apple", "banana", "Mango"]shapes = ["Circle", "Triangle", "Square", "Rectangle"]# Adds both list and print itprint(fruits.append(shapes))print('Current Fruits List:', fruits)# Adding element at the end of list Fruitsfruits.append("Pawpaw") # Using the append() functionprint('Updated Fruits List:', fruits)