lists

Python Lists

Python Lists

Lists in Python are ordered collections of items. You can store multiple values in a single list.

Creating a List

You can create a list by enclosing items in square brackets:

      
        fruits = ["apple", "banana", "cherry"]
        print(fruits)
      
    

This creates a list of fruits and prints it.

Accessing List Elements

You can access elements in a list by their index:

      
        first_fruit = fruits[0]
        print(first_fruit)
      
    

This prints the first element, "apple". Remember that Python uses 0-based indexing.

Activity

Try It Yourself!

Create a list of your favorite movies and print the second one in the list.