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 shows how a path with no ending was fixed.

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 -> hidden pit, game over
  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("\nYou walk down the right path and fall into a hidden pit.")
            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.

ASCII art is full of backslashes, and in a normal Python string a backslash starts an escape sequence like \n. So the art either doubles each backslash (\\ prints one \) or uses a raw string, written with an r before the quotes (r'''...'''), where backslashes are printed exactly as typed. treasure_reward uses a raw string; the title art and the_beast double their backslashes. Without one of the two, Python shows SyntaxWarning: invalid escape sequence and some characters can print wrong.

Every Path Has an Ending

        else:
            print("\nYou walk down the right path and fall into a hidden pit.")
            print(you_lost)

The game tells the player they can go left or right, so both answers need an outcome. An earlier version only handled left: typing right reached the end of the if block and the program simply exited with no message. This else branch for choice2 gives the right path its own ending, and because it’s an else, it also catches any other answer, like a typo.

It’s a good example of why you should test every branch of your conditional logic, not just the “happy path” that leads to the treasure.

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 a fourth decision inside the pit, so the right path can also lead to the treasure
  • 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.

Want to keep learning? These related guides pair well with this post: