Skip to content
← Python for AI/ML · all 50 levels

Nested if

Level 14 of 50 · Decisions & loops

Level 14 of 50

Nested if

explained with a Careem ride. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaMy Careem is here, but I only have 200 rupees!
TeacherTwo checks! Is the ride here? Then, enough cash? That's a nested if!
ride.py
arrived = True
cash = 200

if arrived:
    if cash >= 250:
        print("Pay and go")
    else:
        print("Call Ammi!")
TeacherAn if inside an if! The inner one runs only if the outer is True.
SanaWhy 8 spaces on that print?
TeacherEach if adds 4 more! 8 spaces means it lives inside BOTH!

⏸ Pause & predict: what prints?

eidi = 500

if eidi > 100:
    if eidi > 1000:
        print("Biryani")
    else:
        print("Samosa")
Next: while loop →← elif

Where this leads

Python is step one. Building AI that ships is the rest.

The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.