【发布时间】:2013-08-16 16:50:48
【问题描述】:
所以,下面是相关代码:
def action():
print("These are the actions you have available:")
print("1 - Change rooms")
print("2 - Observe the room (OUT OF ORDER)")
print("3 - Check the room(OUT OF ORDER)")
print("4 - Quit the game")
choice = input("What do you do?\n> ")
if choice in (1, "move"):
return(1)
elif choice in (4, "quit"):
return(4)
play = True
while play == True:
###some functions that aren't relevant to the problem
choice = action()
print(choice)
if choice == 1:
change_room()
## more code...
函数总是返回 None。我把 print(choice) 放在那里看看“choice”有什么值,它总是没有打印,并且“ifchoice == 1”块永远不会运行。所以我猜这个函数根本没有返回一个值,所以错误可能出在 action() 中的 return() 处,但我在这里和其他地方检查过,我看不出它有什么问题。
【问题讨论】:
标签: python function python-3.x return nonetype