Python Lists, Dictionaries and Loops for Excel Users

Python Lists, Dictionaries and Loops for Excel Users
⏱ 2 min readUpdated 27 September 2026

Before pandas, it helps to understand plain Python’s core tools. Almost every automation script is built from lists, dictionaries and loops.

In this article
  1. Lists: an ordered column
  2. Dictionaries: a lookup table
  3. Loops: do something for every item
  4. Putting them together: totals by region

Lists: an ordered column

regions = ["North", "South", "East", "West"]
print(regions[0])        # North  (counting starts at 0)
print(len(regions))      # 4
regions.append("Central")
print(regions[-1])       # Central (last item)

A list is like one Excel column: ordered, and you can add, remove and sort items.

Dictionaries: a lookup table

managers = {"North": "Vikram", "South": "Lakshmi", "East": "Priya"}
print(managers["North"])             # Vikram  — like VLOOKUP
print(managers.get("West", "None"))  # None    — IFERROR built in
managers["West"] = "Farhan"          # add or update

Loops: do something for every item

sales = [12500, 8400, 15200, 6100]
total = 0
for amount in sales:
    total += amount
print(total)          # 42200  — like SUM

big = [s for s in sales if s > 10000]   # like FILTER
print(big)            # [12500, 15200]

Putting them together: totals by region

rows = [("North", 12500), ("South", 8400), ("North", 15200), ("East", 6100)]
totals = {}
for region, amount in rows:
    totals[region] = totals.get(region, 0) + amount
print(totals)   # {"North": 27700, "South": 8400, "East": 6100}  — a pivot table
💡 Python cares about indentation: the lines inside a loop must be indented the same amount (4 spaces is standard).

Next step: pandas for Excel users, which does all of this on whole tables.