What is a list in Python?

A list is an ordered, changeable collection of items written inside square brackets [ ]. A list can hold items of different types and it allows duplicate values.

fruits = ["apple", "banana", "cherry"]
fruits.append("mango")

print(fruits)
print(fruits[0])
print(len(fruits))

Output:

Tutorials Class - Output Window

['apple', 'banana', 'cherry', 'mango']
apple
4

Items are numbered from 0, so fruits[0] is the first item. Because a list is mutable, you can add, remove or change items after creating it. Learn more in the Python Lists chapter.


Learn more about the similar topics:
Tutorials
Python Lists
Python Tuples
Python Sets
Python Dictionary
Exercises & Assignments
Python program to find largest and smallest number in a list
Python program to remove duplicates from a list
Interview Questions & Answers
What is a list in Python?
What is a tuple in Python?
What is a set in Python?
What is a dictionary in Python?
What is a negative index in Python and why is it used?
What is the difference between a list and a tuple in Python?
What are mutable and immutable types in Python?