Python Lists Explained: How to Store Multiple Values in One Place
What if you need to store not just one value but many values at the same time? That is exactly what Python lists are designed for. A list is one of the most useful and flexible tools in Python and once you understand it you will use it in almost every program you write.
WHAT IS A PYTHON LIST?
A list is a collection of values stored in a single variable. Instead of creating ten separate variables for ten items, you put them all in one list.
books = ["Python Made Simple", "Django Made Simple", "ML Made Simple"]
That one line stores three book titles. Clean, organised and easy to work with.
HOW TO CREATE A LIST
Creating a list in Python is simple — use square brackets and separate items with commas:
# List of strings
fruits = ["mango", "banana", "avocado"]
# List of numbers
prices = [1.00, 2.50, 3.99]
# Mixed list
info = ["Benjamin", 30, True, 1.00]
Python lists can hold strings, numbers, booleans — even other lists.
ACCESSING ITEMS IN A LIST
Every item in a list has a position number called an index. Python starts counting from 0:
books = ["Python Made Simple", "Django Made Simple", "ML Made Simple"]
print(books[0]) # Python Made Simple
print(books[1]) # Django Made Simple
print(books[2]) # ML Made Simple
You can also count from the end using negative numbers:
print(books[-1]) # ML Made Simple (last item)
ADDING ITEMS TO A LIST
Use append() to add a new item to the end of your list:
books.append("Firebase Made Simple")
print(books)
Your list now has four items.
REMOVING ITEMS FROM A LIST
Use remove() to delete a specific item:
books.remove("Django Made Simple")
print(books)
LOOPING THROUGH A LIST
Combine lists with loops to process every item automatically:
prices = [1.00, 1.00, 1.00, 1.00]
total = 0
for price in prices:
total = total + price
print("Total earnings: $" + str(total))
USEFUL LIST METHODS TO KNOW
- len(list) — returns the number of items
- list.sort() — sorts items alphabetically or numerically
- list.reverse() — reverses the order
- list.count(item) — counts how many times an item appears
- list.clear() — removes all items
REAL WORLD EXAMPLE: BOOK STORE INVENTORY
inventory = ["Python Made Simple", "Django Made Simple", "ML Made Simple", "Firebase Made Simple"]
print("Total books in store:", len(inventory))
print("First book:", inventory[0])
print("Last book:", inventory[-1])
inventory.append("Data Science Made Simple")
print("Updated inventory:", inventory)
WHY LISTS ARE SO IMPORTANT
Lists are the foundation of almost every real program. When you fetch data from a database, it comes as a list. When you train a machine learning model, your data is stored in lists. When you build an Android app that shows items on screen, you use a list. Master lists now and everything else becomes easier.
KEEP LEARNING WITH PYTHON MADE SIMPLE
Lists are just one of the many powerful Python concepts covered in Python Made Simple by Benjamin Koikoi. Every chapter is written in plain English with practical examples you can run immediately. Get your copy today for just $1 on Gumroad and Amazon KDP. Best one dollar you will ever spend on your coding education.

Comments
Post a Comment