Skip to content
beginner

Lists in Python

If you’ve ever wanted to keep track of a grocery list, a group of friends, or a collection of numbers, you already understand why storing multiple values…

Published 2026-05-11Updated 2026-05-127 min read

If you’ve ever wanted to keep track of a grocery list, a group of friends, or a collection of numbers, you already understand why storing multiple values is so important in programming. In Python, the tool for this job is called a list. Lists are one of the most useful Python data structures, and they’re a must-know for anyone starting their programming journey.

Let’s explore what Python lists are, how to use them, and why they’re so handy for real-world programming tasks.


What Is a List in Python?

A list in Python is a way to store several values together in a single variable. Think of a list as a container or a box that can hold many items, not just one.

For example, if you wanted to store the names of your three favorite movies, you could use three separate variables:

movie1 = "Inception"
movie2 = "Toy Story"
movie3 = "Spirited Away"

But what if you had 10 movies? Or 100? Creating a new variable for each one would be a nightmare! This is where Python lists come in.

With a list, you can store all your movie names in one place:

movies = ["Inception", "Toy Story", "Spirited Away"]

Lists are a type of data structure in Python. Data structures help organize and manage data efficiently. Unlike variables that hold a single value, lists can hold as many values as you need, all in one variable.

Quiz time!

Quiz Question 1

Question: Which of the following creates a list containing the numbers 5, 10, and 15 in Python?

  • A) numbers = [5, 10, 15]
  • B) numbers = (5, 10, 15)
  • C) numbers = {5, 10, 15}

How to Create a List

Creating a list in Python is simple. You use square brackets [] and separate each item with a comma.

Here’s how you can make a list of numbers:

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

Lists can also hold different types of values. You can mix strings, numbers, and even other lists:

mixed_list = ["apple", 3, 4.5, True]

You can even create an empty list (which has no items yet):

empty_list = []

This flexibility is one reason why Python lists are so popular and useful.

Common question:
Can I put different types of data (like numbers and strings) in the same list?
Yes! Python lists can store any mix of data types.


Accessing Items in a List

Each item in a list has a position, called an index. In Python, indexes start at 0. This is known as zero-based indexing.

Here’s an example:

colors = ["red", "green", "blue"]
  • colors[0] is "red"
  • colors[1] is "green"
  • colors[2] is "blue"

To get an item from a list, use the list name followed by the index in square brackets:

print(colors[1])  # Output: green

If you try to access an index that doesn’t exist (like colors[3]), Python will give you an error. Always remember: counting starts at 0!

Why do list indexes start at 0 instead of 1?
This is a common convention in programming. It helps with certain calculations and is used in many languages, not just Python.


Changing and Updating List Items

One of the best things about Python lists is that they are mutable. This means you can change their contents after you create them.

Suppose you want to update the second color in your list:

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

You can change any item in the list by assigning a new value to its index.

What does it mean that lists are mutable?
It means you can change, add, or remove items after the list is created.


Adding and Removing Items

Lists in Python can grow and shrink as you need them. Here are some of the most common ways to add and remove items:

Adding Items

  • append() adds an item to the end of the list:

    fruits = ["apple", "banana"]
    fruits.append("cherry")
    print(fruits)  # Output: ['apple', 'banana', 'cherry']
    
  • insert() adds an item at a specific position:

    fruits.insert(1, "orange")
    print(fruits)  # Output: ['apple', 'orange', 'banana', 'cherry']
    

What's the difference between append() and insert()?
append() always adds to the end, while insert() lets you choose the position.

Removing Items

  • remove() deletes the first matching value:

    fruits.remove("banana")
    print(fruits)  # Output: ['apple', 'orange', 'cherry']
    
  • pop() removes an item by its index (and returns it):

    last_fruit = fruits.pop()
    print(last_fruit)  # Output: cherry
    print(fruits)      # Output: ['apple', 'orange']
    

How do I remove an item if I don't know its index?
Use remove() with the value you want to delete.

Quiz time!

Quiz Question 2

Question: What does the append() method do in a Python list?

  • A) Adds an item to the end of the list
  • B) Removes the last item from the list
  • C) Inserts an item at the beginning of the list
  • D) Sorts the list in order

When to Use Lists in Real Life

Python lists are everywhere in real-world programming. Here are just a few examples of how lists can help you solve everyday problems:

  • To-do lists: Keep track of tasks you need to finish.
  • User data: Store a group of usernames or email addresses.
  • Game scores: Save scores for each player in a game.
  • Shopping carts: Hold the items a user wants to buy in an online store.
  • Sensor readings: Collect temperature or other data from sensors over time.

Whenever you need to keep track of a group of related items, Python lists are usually the go-to solution. They are one of the most flexible and beginner-friendly Python data structures.


More Common Questions About Python Lists

Are lists and arrays the same thing in Python?
In Python, lists are more flexible than arrays in some other languages. There is a separate array type in Python, but for most beginner tasks, lists are what you want.

Is there a limit to how many items a Python list can hold?
Practically, only the memory of your computer limits the size of a list.

How do I add an item to the beginning of a list?
Use insert(0, item) to add at the start.

How do I make a copy of a list?
You can use my_list.copy() or my_list[:] to make a copy.


Wrapping Up: Why Python Lists Matter

Lists are one of the most important building blocks in Python programming. They let you store, organize, and manage collections of data with ease. Whether you’re keeping track of names, numbers, or anything else, Python lists make your code more powerful and flexible.

The best way to get comfortable with lists is to practice. Try making your own lists, adding and removing items, and using them in small projects. As you continue your Python journey, you’ll discover even more about Python data structures and how they can help you solve real-world problems.

Ready to keep learning? Check out our next tutorials on other Python data structures, like dictionaries and tuples, to expand your programming toolkit!


Quiz Answer Key

Question 1

Correct answer: A) numbers = [5, 10, 15]

Explanation: Lists in Python are created using square brackets []. Parentheses create tuples, and curly braces create sets.

Question 2

Correct answer: A) Adds an item to the end of the list

Explanation: The append() method adds a new item to the end of an existing list.

Keep learning

Related tutorials

Continue with nearby Python topics and beginner-friendly explanations.

beginner8 min read

Basic File I/O in Python

Learning to work with files is one of the most practical skills you can pick up as a beginner Python programmer. Whether you want to save your notes, read…

Read tutorial
beginner6 min read

Dictionaries in Python

Have you ever kept a list of names and phone numbers, or flipped through a glossary to find the meaning of a word? In both cases, you’re matching one piece…

Read tutorial