Dark theme

The key piece of information for building our story is that you can nest if-statements inside each other, like this:

decision = input("Do you want to enter? [Y,N]: ")
if decision == "N" or decision == "n":
    print("Your quest is at an end, goodbye!")
elif decision == "Y" or decision == "y":
    print("You enter the mines.")
    print("The way is lit by candles on the wall.")
    decision = input("You come to a junction. Turn left or right [L,R]: ")
    if decision == "L" or decision == "l":
        print("You turn left and see a terrible ogre!")
    elif decision == "R" or decision == "r":
        print("You turn right and see a terrible spider!")
    else:
        print("You turn back, coward! Goodbye!")
else:
    print("A hole opens up below you, and you plunge into darkness. Goodbye!")

The main thing is to make sure you keep indenting properly. Each time you have a decision, you push that decision's blocks another four spaces across. You can help keep track of this if you use plenty of whitespace (blank lines) to show which bits of code go together:

decision = input("Do you want to enter? [Y,N]: ")
if decision == "N" or decision == "n":
    print("Your quest is at an end, goodbye!")
elif decision == "Y" or decision == "y":


    print("You enter the mines.")
    print("The way is lit by candles on the wall.")
    decision = input("You come to a junction. Turn left or right [L,R]: ")

    if decision == "L" or decision == "l":
        print("You turn left and see a terrible ogre!")
    elif decision == "R" or decision == "r":
        print("You turn right and see a terrible spider!")
    else:
        print("You turn back, coward! Goodbye!")


else:
    print("A hole opens up below you, and you plunge into darkness. Goodbye!")

You should have enough now to start to pull together your own story game...

[Home > Part 1 > Next]