2015-10-31 39 views
1

我在我的基於文本的冒險的第36行收到語法錯誤。第36行的語法錯誤

我在行尾添加了#line 36來告訴你它在哪裏。 我已經嘗試了所有我能想到的方法來解決這個問題。我錯過了什麼?

#Adventure 
#Setting 
print ("*You wake up in a dark room on a mattress that is on the floor*") 
#Wait before running next command to make it seem more real and more like a real thought. 
import time 
time.sleep(1) 
#Introduce the Map 
print ("*You look to your left and there is a wall, you then look to your right and find a short table with a map on it*") 
import time 
time.sleep(1) 
print("*You pick up the map*") 
map = """ 
         |---------------------| 
         |      | 
         |  Start  | 
         |      | 
         |      | 
         |---------------------|""" 
print (map) 
def goto(linenum): 
    global line 
    line = linenum 
line = 1 
while True: 
    if line == 1: 
     response = raw_input("Would you like to explore around the room or move to next the room? (Type explore ,or move-on): ") 
     if response == "explore": 
      map = """ 
         |---------------------|---------------------| 
         |      |      | 
         |  Start  |  Room 2   | 
         |      |      | 
         |      |      | 
         |---------------------|---------------------|""" 
    print (map) 
     elif response = "move-on": #line 36 
      map = """ 
         |-------------------------------------------| 
         |           | 
         |  [Chest]       | 
         |          D | 
         |          O | 
         |          O | 
         |  (table)       R | 
         |  {Bed}        | 
         |-------------------------------------------|""" 
print (map) 
     else: 
      goto(100) 

     break 
    elif line == 100: 
     print "Your input is invalid" 
     goto(1) 

回答

1

你不需要導入模塊多次(即只import time一旦開頭)..

這樣說,打印聲明:

print (map) 

是不正確縮進(這兩次被稱爲[第35行和第47行])

也可能有其他問題,但這是你的代碼目前正在吹襲的那個。

1

變化elif response = "move-on": #line 36變爲elif response == "move-on": #line 36。你忘記了等號

相關問題