3
class TheBridge(Scene):
def enter(self):
print "You burst into the bridge with the bomb"
print "There are a number of gothons standing about"
print "and looking scared of the bomb you currently have underneath your arm"
print "They look nervous about what you are going to do"
action = raw_input("> ")
if action == "Throw the bomb":
print "You throw the bomb at the gorcons on the bridge"
print "They pure and utter crap themselves and pull out their laser blasters and shhot you dead"
print "at least the bomb will kill the gorcons, you die a hero"
return 'death'
elif action == "Put the bomb down slowly":
print "You pull you laser blaster from your holster and point it at the bomb"
print " You very slowly set the bomb on the ground and move backwards"
print "You then jump back through the door and start firing your gun at the"
print "lock and you blast it so the gorcons can't escape"
print "You then procede to try and find an escape pod"
return 'escape_pod'
else:
print "DOES NOT COMPUTE"
return "the_bridge"
它出於某種原因拋出語法錯誤。也許我是一個完全白癡,看不到明顯的東西。絕對不是間距或縮進或類似的東西,因爲我已經檢查過。這個elif語句爲什麼會拋出一個錯誤?
任何想法?
錯誤消息:
File "ex43.py", line 131
elif action == "Put the bomb down slowly":
^
SyntaxError: invalid syntax`
請顯示周圍的代碼,包括前面的if語句。 – BrenBarn
還顯示錯誤消息,以便我們可以幫助您解密它。 Python錯誤信息非常豐富,你應該學會閱讀它們。 –
「絕對不是間距或縮進或類似的東西,因爲我已經檢查過了。」我會檢查'def enter(self)'的縮進。' – YuppieNetworking