【发布时间】:2016-03-04 18:07:06
【问题描述】:
我对编程还很陌生,并且已经开始编写基于文本的游戏。
但是,我不断遇到两个错误;意外的取消缩进和语法错误。
我正在使用try,但它告诉我except 上的语法错误,如果我在except 之后删除整个块,它会在下一行给我一个“Unexpected Unndent”错误(在“左门”),突出显示空白。
def prompt_chouseroom1():
prompt_2 = raw_input ("You know what to do by now: ")
try:
if prompt_2 == ("Look around the room"):
print ("You see two doors; one on the left, and one on the right. There is also a dead body in the middle of the room")
print promt_chouseroom1 ()
if prompt_2 == ("Go through left door"):
left_door()
if prompt_2 == ("Go through middle door"):
prinnt ("WHAT?! You walked through the wall!")
middle_door()
if prompt_2 == ("Go through right door"):
right_door()
if prompt_2 == ("Look under the rug"):
print ("Oh my... you... you weren't supposed to find that. Well... looks like you can leave already. You win. Congrats... I guess :( ")
win_game()
else:
print ("Try to LOOK AROUNF THE ROOM.... just a hint ;)")
print
prompt_chouseroom1()
except ValueError:
print ("Try to LOOK AROUNF THE ROOM.... just a hint ;)")
print
prompt_chouseroom1()
def left_door():
【问题讨论】:
-
查看
try的缩进。查看except的缩进。这些行的缩进看起来有什么问题吗?