Lists and Tuples

Lists and tuples are used to store collections of items in Python.

Lists

Lists are mutable, meaning they can be changed.

fruits = ["apple", "banana", "cherry"]
fruits.append("orange")
print(fruits[0])  # Output: apple

Tuples

Tuples are immutable and faster than lists for fixed data.

colors = ("red", "green", "blue")
print(colors[1])  # Output: green
Next →