Lists

Have you ever needed to remember a whole list of things, like your favorite movies or a grocery list? In Python, we use Lists to store many pieces of information together in one single variable.

What are Python Lists?

A List is a collection of items kept in a specific order. Each item in a list gets its own "seat number," which we call an index.

The most important thing to remember is that Python starts counting at 0!

  • The 1st item is at index 0.

  • The 2nd item is at index 1.

Real-World List Scenarios

  • Shopping List: ["Milk", "Bread", "Eggs"]

  • Music Playlist: A list of your favorite songs.

  • Classroom: A list of student names.

  • Gaming: A list of high scores or inventory items.

How it Looks (Syntax & Examples)

Lists are very flexible. You can add new items, update (change) them, or delete them whenever you want!

Example: Updating your Marks

# Creating a list of marks
marks = [80, 90, 75]

# Changing the first item (index 0) to 100
marks[0] = 100

print(marks)


Output: [100, 90, 75]

Summary:

  • Ordered: Python remembers exactly what order you put your items in.

  • Changeable: Unlike some other structures, you can change a list after creating it (this is called being mutable).

  • Diverse: A single list can hold numbers, words, or even other lists!

  • Index Power: You can grab any item instantly if you know its position.

Check your knowledge

Quickly verify what you've learned from this tutorial.

Question 1

What symbol is used to create a List in Python?

Python Lists are always defined using square brackets [ ].

Question 2

What is the index number of the very FIRST item in a Python list?

In programming, we use zero-based indexing, meaning the count always starts at 0.

Question 3

If you have a

list fruits = ["Apple", "Banana", "Cherry"], 

what is fruits[1]?

Since Apple is at index 0, Banana is the item located at index 1.

Question 4

Why are Lists considered "Mutable"?

Mutable is a fancy coding word that means the data structure can be modified after it is made.

Question 5

Look at the following code carefully. What will be the final output?

numbers = [10, 20, 30, 40, 50]

for n in numbers:
    if n == 30:
        continue
    if n == 50:
        break
    print(n)

The program skips 30 because of the continue statement, prints 40, and then stops completely when it hits 50 because of the break statement.

Congratulations!

You've successfully mastered the knowledge check for "Lists."

For more questions and practice, click the link below:

Practice More Questions
Previous Topic continue Statement Next Topic Creating Lists