我對編程相當陌生,並開始編寫基於文本的遊戲。意外的Unindent和語法錯誤
但是,我不斷遇到兩個錯誤;意外的Unindent和語法錯誤。
我使用try
但它告訴我一個語法錯誤上except
,如果我得到except
後襬脫了整個塊的它,然後給我的下一行「意外取消縮進」錯誤(「左門」後)突出空白空間。
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'的縮進。這些線條的縮進是否有任何問題? – user2357112