📅  最后修改于: 2023-12-03 15:04:05.887000             🧑  作者: Mango
The append()
method in Python is used to add an element to the end of a list. It modifies the original list and returns None
.
The syntax for append()
is:
list.append(element)
Where:
list
is the list to which the element will be appended.element
is the object that is added to the end of the list.fruits = ['apple', 'banana', 'mango']
fruits.append('orange')
print(fruits)
Output:
['apple', 'banana', 'mango', 'orange']
append()
method adds an element to the end of a list.None
.append()
method multiple times.append()
does not create a new list, it modifies the original list.extend()
method instead.For more details, refer to the official Python documentation here.