函数未在“内部运行”;如果;语句Python 3

函数未在“内部运行”;如果;语句Python 3,python,python-3.x,Python,Python 3.x,我正试图用Python编写一个越狱游戏。 当我使用pycharm运行代码时,进程以“processfinished with exit code 0”结束 函数的定义有问题吗? 这是我的代码(有点长): 我认为这可能是最后一个“如果”语句,但我不是肯定的。您需要将choice==input(“Make your choice:”)更改为choice=input(“Make your choice:”)函数中的main\u choice: def main_choice(): print

我正试图用Python编写一个越狱游戏。
当我使用pycharm运行代码时,进程以“processfinished with exit code 0”结束

函数的定义有问题吗?
这是我的代码(有点长):


我认为这可能是最后一个“如果”语句,但我不是肯定的。

您需要将
choice==input(“Make your choice:”)
更改为
choice=input(“Make your choice:”)
函数中的
main\u choice

def main_choice():

    print("1. Examine door")

    print("2. Examine painting")

    print("3. Examine desk")

    print("4. Examine bookshelf")

    choice = input("Make your choice: ")

否则,
choice
变量仍将是
None
,如果choice==“1”:将始终为False。

您需要将
choice==input(“Make your choice:”)
更改为
choice=input(“Make your choice:”)
main\u choice
函数中:

def main_choice():

    print("1. Examine door")

    print("2. Examine painting")

    print("3. Examine desk")

    print("4. Examine bookshelf")

    choice = input("Make your choice: ")
否则
choice
变量仍将是
None
,如果choice==“1”:
将始终为False。

您应该编写:

choice = input("Make you choice: ")
而不是:

choice == input("Make you choice: ")
双等号返回布尔值,而不是更改值。

您应该写:

choice = input("Make you choice: ")
而不是:

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

双等号返回布尔值,而不是更改值。

基本上您想继续运行程序而不退出吗?一种快速调试方法是在调用
main\u choice()后放置调试打印
以确保您已首先将
choice
分配给某个对象。基本上,您是否希望继续运行程序而不退出?一种快速的调试方法是在调用
main\u choice()
后放置调试打印,以确保您已首先将
choice
分配给某个对象。