The append()
method is a List method in Python that is used to add a new element to the end of a list. It modifies the original list in place and does not return a new list. The syntax for using append() is list_name.append(element)
where 'list_name' is the list to which the element is to be added.
Parameter Values
Parameter | Description |
---|---|
element | The element to be appended to the list |
Return Values
The append()
method in Python doesn't return any value; it returns None
.
How to Use append()
in Python
Example 1:
The append()
method adds a single element to the end of a list.
numbers = [1, 2, 3]
numbers.append(4)
print(numbers)