Python List append() Method | .com
Python Basic Tutorials
- Python Basic Tutorial
- Python Introduction
- Python Environment Setup
- Python Chinese Encoding
- Python VS Code
- Python Basic Syntax
- Python Variable Types
- Python Operators
- Python Conditional Statements
- Python Loop Statements
- Python While Loop Statement
- Python for Loop Statement
- Python Nested Loops
- Python break Statement
- Python continue Statement
- Python pass Statement
- Python Number (Numbers)
- Python Strings
- Python Lists (List)
- Python Tuples
- Python Dictionary
- Python Date and Time
- Python Functions
- Python Modules
- Python File I/O
- Python File Methods
- Python Exception Handling
- Python OS File/Directory Methods
- Python Built-in Functions
Python Advanced Tutorials
- Python Object-Oriented Programming
- Python Regular Expressions
- Python CGI Programming
- Python MySQL
- Python Network Programming
- Python SMTP Email Sending
- Python Multithreading
- Python XML Parsing
- Python GUI Programming (Tkinter)
- Python 2.x vs 3.x Version Differences
- Python IDE
- Python JSON
- Python AI Drawing
- Python 100 Examples
- Python Quiz
Python List append() Method
The append() method adds a single element to the end of the list.
Syntax:
list.append(element)
Parameters
- element: The element to be added to the list. It can be any data type, such as a number, string, or another list.
Returns
No return value (returns None).
Example
Add an element to the end of a list:
fruits = ['apple', 'banana']
fruits.append('cherry')
print(fruits)
# Output: ['apple', 'banana', 'cherry']
Notes
- Only one element can be added at a time using
append(). - If you want to add multiple elements, use the
extend()method instead. - The
append()method modifies the original list in place and does not create a new list.
Note: This method is very useful when dynamically building lists during program execution.
YouTip