HOW TO

How to read & understand code written by someone else (and eventually be able to change it confidently)”

This is actually one of the top 3 most valuable real-world programming skills.

Let’s go very slowly and clearly — like I’m sitting next to you with a cup of chai. ☕

Step 1: Change your mindset first (most important part)

Most beginners think:

“I should understand every line immediately → if I don’t, I’m bad at coding.”

Reality (please remember this forever):

Good developers do NOT understand code instantly. They do exactly what I’m going to show you — slowly, line by line, like detectives.

So first promise to yourself:

“It’s completely okay if I don’t understand it on the first reading. My job is to investigate, not to be a genius in 10 seconds.”

Step 2: The golden 7-step method I use (and teach everyone)

Let’s take this very common real example that scares almost everyone when they first see it:

Python

Terrifying at first? Yes. Understandable in 10–15 minutes? Also yes — if you follow the system.

Here’s exactly how I would explain it to you in person:

1. First — read the function name and parameters (10 seconds)

Python

Questions I ask myself out loud:

  • What does this function probably do?
  • What is users? (probably a list of dictionaries)

Answer: It takes a list of user dictionaries and “processes” them somehow → probably cleans them / transforms them / filters them.

2. Look at what the function returns (very important!)

Python

→ it returns a list → and inside the list there are dictionaries (because I see { … })

So most likely: it transforms the input list into a new, cleaner list of dictionaries.

3. Check if there’s a filter happening

Look for if outside the dictionary:

Python

only users where active is True will be included → inactive users are completely ignored

So now we know:

This function filters active users only and transforms them.

4. Now read one transformed user object — slowly, line by line

Python

Let’s break each key-value pair:

  • “id”: u[“user_id”] → just renaming “user_id” → “id” (common cleanup)

  • “full_name”: f”{u[‘first’]} {u[‘last’]}”.title() → take first name + space + last name → make it Title Case (first letter of each word capital) Example: “john” + ” ” + “doe” → “john doe” → “John Doe”

  • “is_adult”: u.get(“age”, 0) >= 18 → get age, if no age exists → use 0 → check if age ≥ 18 → gives True or False

  • “tags”: [t.upper() for t in u.get(“interests”, []) if len(t) > 3] This line scares people most — let’s destroy the fear:

    It is just a list comprehension with a filter.

    Let’s write it the long ugly way first:

Python

So:

  • take each interest
  • if it has more than 3 letters
  • make it UPPERCASE
  • keep it in the new list

Examples:

Python

5. Put everything together in plain English

This function:

  • Takes a list of user dictionaries
  • Keeps only active users
  • For each active user creates a new simpler dictionary with:
    • id (renamed from user_id)
    • full_name (First Last in title case)
    • is_adult (True/False)
    • tags (uppercase interests that are longer than 3 letters)

6. Test it mentally with example data

Input:

Python

What should come out?

Only alice and clara are active.

Output:

Python

Perfect.

7. Last step: Say it out loud in one sentence

“This function cleans a list of users, keeps only active people, renames some keys, creates a proper full name, checks if they’re adult, and keeps only longer interests in uppercase.”

Now you understand 100% of it.

Summary: Your personal “I’m stuck” checklist

Whenever you see scary code:

  1. Read function name + parameters
  2. Look at what it returns
  3. Check if there’s filtering (if outside)
  4. Read one created item slowly — key by key
  5. Translate short lines into long obvious code
  6. Test mentally with 2–3 example items
  7. Say the whole purpose in one normal English sentence

Do this 30–40 times and you’ll become scary-good at reading other people’s code.

Would you like me to do exactly the same detailed breakdown for:

  • nested loops
  • recursion
  • list/dict/set comprehensions
  • classes & objects (OOP)
  • async/await
  • error handling (try/except)
  • decorators
  • regular expressions
  • OR any other topic you’re struggling with right now?

Just tell me what you want to truly understand — I’ll go just as slowly and clearly. 😄