0

I'm attempting to write an escape room game in Python.
When I run the code with pycharm the process ends with "process finished with exit code 0."

Is there something wrong in the defining of the functions?
Here is my code (its a bit lengthy):

choice = None

def main_choice():

    print("1. Examine door")

    print("2. Examine painting")

    print("3. Examine desk")

    print("4. Examine bookshelf")

    choice == input("Make your choice: ")


def door():

    print("1. Try to open door")

    print("2. Take a closer look")

    print("3. Go back to where you were.")

    door_choice = input("What now? ")

    if door_choice == "1":

        print("The door is too heavy to open with your bare hands.")

        door()

    if door_choice == "2":

        print("There is a red light above the door, but it seems to have no purpose.")

        print("You notice a 9 key keypad next to the door. It looks like it will accept a 3 digit code.")

        keypad_code = input("Would you like to enter a code?").lower

        if keypad_code == " yes":

             guess = input("ENTER CODE: ")

             if guess == complete_key:

             print("The light turns green and you hear the sound of a mechanical lock unlocking. The door opens.")

             print("YOU WIN!!!")

        if guess != complete_key:

             print("Wrong code.")

             main_choice()

    if door_choice == "3":

        main_choice()

    else:

        print("You didn't answer")


main_choice()

if choice == "1":

    print("You walk to the door")

    door()

I think that it might be the last "if" statement, but I'm not positive.

2
  • basically do you want to keep running program without exit? Commented Nov 6, 2016 at 3:10
  • A quick way to debug this would be to place a debug print after you call main_choice() to ensure you have assigned choice to something first. Commented Nov 6, 2016 at 3:17

2 Answers 2

1

You need to change choice == input("Make your choice: ") to choice = input("Make your choice: ") in your main_choice function:

def main_choice():

    print("1. Examine door")

    print("2. Examine painting")

    print("3. Examine desk")

    print("4. Examine bookshelf")

    choice = input("Make your choice: ")

Otherwise the choice variable will still be None and if choice == "1": will always be False.

Sign up to request clarification or add additional context in comments.

Comments

1

You should write:

choice = input("Make you choice: ")

rather than:

choice == input("Make you choice: ")

Double equals signs return a boolean rather than changing a value.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.