How do you add a new item to a list in Python?

Experience Level: Junior
Tags: Python

Answer

To add a new item to a list, use .append() method.

Example:

items = list["red", "amber"]
items.append("green")

Python for beginners
Python for beginners

Are you learning Python ? Try our test we designed to help you progress faster.

Test yourself