Day 002 of the 100 Days of Python challenge turns Python conditionals into a small text adventure: The Pyramid Escape Room. The player must answer a riddle, choose a path, and select the safe door to find the treasure.

Where Day 001 focused on numbers and math, Day 002 shifts to decision-making — the if, elif, and else statements that let a program react differently depending on what the user types. Nesting those conditionals inside one another is exactly how this project builds a branching story, and it’s a pattern you’ll reuse constantly once you move on to more complex programs.

This guide breaks down the full Day 002 source code, walks through how the nested conditionals control the story, and points out a couple of edge cases worth noticing in the original logic.

Project Overview

The game begins with a keyboard riddle. A correct answer opens a hidden chamber with two paths. Choosing the left path leads to three color doors: red, yellow, and blue.

  • Red door — a room full of fire; the player loses.
  • Yellow door — the treasure; the player wins.
  • Blue door — a room full of beasts.

The program uses input().lower() so the player’s answers are compared consistently even when capitalization differs. Nested if, elif, and else blocks represent the branching story.

The Decision Tree

Riddle: keyboard?
  Yes -> choose left or right
    Left -> choose red, yellow, or blue
      Red    -> room of fire, game over
      Yellow -> treasure, you win
      Blue   -> room of beasts
    Right -> (no outcome defined)
  No -> "Wrong answer" message

Source Code

The Day 002 project is contained in day002/main.py in the 100daysofpython repository. The core logic, with the large ASCII art blocks trimmed for readability here (see the link above for the full art):

def main():

    # ASCII art title screen (trimmed here — see the repo for the full art)
    print('''...pyramid title art...''')

    print("Welcome to The Pyramid Escape Room.")
    print("Your mission is to find your way out and discover the treasure.\n")
    print("You walk into a room and realize you are inside a pyramid.")
    print("There are two signs on the wall and a door in front of you.\n")
    print('"Choose the right answer only. Wrong answers will end your game."')
    print("*****************************************************************\n")

    # FIRST DECISION (RIDDLE)
    print("First Choice - The Riddle:")
    print("I have keys but no locks,")
    print("I have space but no room,")
    print("You can enter, but you can't go outside.")
    print("What am I?\n")

    choice1 = input("Your answer: ").lower()
    if choice1 == "keyboard":
        print("\nCorrect! A hidden door opens.")

        # SECOND DECISION (PATH)
        print("\nInside the chamber you see two paths: left and right.")
        choice2 = input("Which way do you go? (left/right): ").lower()
        if choice2 == "left":
            print("\nYou walk down the left path and find three color doors.")
            print("Only one is safe!\n")

            # THIRD DECISION (DOORS)
            choice3 = input("Choose a door: red, yellow, or blue: ").lower()
            if choice3 == "red":
                print("\nIt's a room full of fire!")
                print(you_lost)
            elif choice3 == "yellow":
                print("\nYou found the treasure! You Win!")
                print(treasure_reward)
            elif choice3 == "blue":
                print("\nYou enter a room of beasts!")
                print(the_beast)
            else:
                print("\nWrong door. The floor collapses.")
                print(you_lost)
    else:
        print("\nWrong answer. The floor collapses.")
        print(you_lost)


if __name__ == "__main__":
    main()

The full file also defines three large triple-quoted strings — treasure_reward, you_lost, and the_beast — each holding ASCII art printed at the corresponding ending. See the complete source on GitHub for the full art.

How the Program Works

Nested Conditionals Model the Story

Each decision is nested inside the previous one’s if block, so a choice only becomes reachable once every earlier condition has been satisfied. Answer the riddle wrong, and the player never even sees the door choice — the else at the outermost level ends the game immediately.

Normalizing Input with .lower()

choice1 = input("Your answer: ").lower()

Calling .lower() on the result of input() means "Keyboard", "KEYBOARD", and "keyboard" are all treated identically, since the comparison (choice1 == "keyboard") only ever checks against a lowercase string.

Large Strings Double as Scenery

Assigning ASCII art to variables like treasure_reward and the_beast keeps the branching logic readable — the if/elif/else block stays focused on the story’s structure, while the visual detail lives separately and gets printed only when that ending is reached.

An Edge Case Worth Noticing

Look closely at the second decision: the code only handles choice2 == "left". If the player types "right" — one of the two options the game itself suggests — nothing happens. The program reaches the end of the if choice1 == "keyboard": block and simply exits with no message at all.

This is a great example of why testing every branch of your own conditional logic matters, not just the “happy path.” A beginner-friendly fix would be adding an else for choice2 that prints its own ending, so every documented choice actually leads somewhere.

What This Project Teaches

Day 002 demonstrates:

  • Conditional statements (if, elif, else)
  • Nested conditions representing multi-step decisions
  • String normalization with .lower()
  • Reading and responding to user input
  • Designing a simple decision tree for a text-based game

Running the Project

git clone https://github.com/victorhugo81/100daysofpython.git
cd 100daysofpython/day002
python main.py

Possible Next Steps

The original project’s own README suggests moving each scene into a function and validating the accepted choices more explicitly, which would make the story easier to expand without deeply nested code. A few other beginner-friendly improvements:

  • Add an else branch for choice2 so choosing “right” leads to its own ending instead of silently exiting
  • Let the player replay the game with a loop instead of exiting after one attempt
  • Track and display how many attempts it took to find the treasure
  • Add a hint system if the player answers the riddle incorrectly more than once

Conclusion

Day 002 of the 100 Days of Python challenge turns basic if/elif/else logic into an interactive text adventure, showing how nested conditionals can model a branching story one decision at a time. It also demonstrates a valuable lesson beyond syntax: even a small, working program can have untested branches, which is exactly the kind of thing careful testing catches.

View the Day 002 source code on GitHub, then continue through the repository’s project index as you build more Python programs, one day and one small project at a time.