blogs for-shariq

Python for Dummies Pt.3: Lists (Because multiple variables are for masochists)

Published: Mar 8, 2026

Enter Lists. A list is essentially a single box where you can throw all your data so it’s not cluttering up the rest of your script.

1. Creating a List

In Python, we use square brackets []. Items are separated by commas. It’s the only part of your life that will actually stay organized.

# A list of things that actually matter
cool_gadgets = ["iPhone", "Drone", "VR Headset"]

# A list of numbers (Riveting stuff)
lucky_numbers = [7, 11, 21, 42]

# You can even mix types if you're feeling chaotic
mixed_bag = ["Shariq", 15, True, 9.5]

print(f"My gadgets: {cool_gadgets}")

2. How to Grab an Item (Indexing)

Every item has an "index" (an address). Now, pay attention because this is where people trip up: Python starts counting at 0. If you try to call the first item "1," Python will look at you like you’re speaking a dead language.

  • The 1st item is [0].
  • The 2nd item is [1].
fruits = ["Apple", "Banana", "Cherry"]

# Grabbing the first item (Index 0, obviously)
print(f"The first fruit is: {fruits[0]}")

# Grabbing the last item
# We use -1 because we're too lazy to count how long the list is
print(f"The last fruit is: {fruits[-1]}")

3. Changing and Adding Items

Lists are mutable. That’s just a fancy computer science word for "you can change your mind later."

Action What it actually does
Change Overwrites whatever was already there.
.append() Tacks something onto the end of the list.
.remove() Deletes your mistakes.

Here is the text after the table. Note the blank line above this.

inventory = ["Sword", "Shield", "Potion"]

# Upgrading the sword because basic gear is for losers
inventory[0] = "Laser Gun"

# Found something else? Stick it at the end.
inventory.append("Map")

print(f"Updated Inventory: {inventory}")

4. Useful List Tricks

A couple of tools so you don't have to do the manual labor yourself:

  • len(): Tells you how many items are in the list (so you don't have to count like a toddler).
  • in: Checks if an item exists in the list. It returns True or False.
colors = ["Red", "Blue", "Green"]

# How many colors do we have to deal with?
print(f"I have {len(colors)} colors.")

# Checking if 'Purple' exists (Spoiler: it doesn't)
print(f"Is Purple in the list? {'Purple' in colors}")

There you go. You can now manage a whole collection of data without losing your mind. Next time, we’ll talk about Loops, which is basically how we force the computer to do the same boring task over and over again so we don't have to.