Python List - append method

Method Name: 

append

Method Signature:

append(element_in)

Method Overview:

  • The append() method adds an element to the end of a Python list object.

Parameters:

element_in: The element to be added to the Python list

Return Value:

None

Example:

# Example Python program that appends
# an element to a Python list

# Create a list with few elements
ironOres = ["Magnetite", "Hematite", "Limonite"];

# Append an element to the end of the list
ironOres.append("Siderite");
print("Iron ores:");
print(ironOres);

Output:

Iron ores:
['Magnetite', 'Hematite', 'Limonite', 'Siderite']

 


Copyright 2024 © pythontic.com