2016-05-15 88 views
-4
def consequence_0(): 
    consequence_0() = input ("Now you can see into darker places...") 
    try: 
     if consequence_0 == 'shiny object': 
      print ("You picked up a key") 
     elif consequence_0 == 'pick up shiny object': 
      print ("You picked up a key") 
    except ValueError: 
     print ("You can't carry out that action") 
     print 

def consequence_1(): 
    consequence_1() = input() 
    try: 
     if consequence_1 == 'open bible': 
      print ("The bible opens and you see a single page attached to the inside of the cover") 
     elif consequence_1 == 'open the bible': 
      print ("The bible opens and you see a single page attached to the inside of the cover") 
    except ValueError: 
     print ("You can't carry out that action") 
     print 
+1

你可以請張貼堆棧跟蹤? ...然而,'outcome_0()= input'是一個函數調用,你正在嘗試賦值給它。你想達到什麼目的? – tdelaney

+0

你認爲'()'做了什麼?你可能想尋求一個教程。 – TigerhawkT3

+0

命名建議:沒有理由在它們所在的函數之後爲局部變量命名,特別是沒有理由說明用戶輸入的任何名稱都應該知道它在處理用戶輸入的_n_-th函數中。記住「輸入」(令人沮喪地是名詞和動詞)已經被內置的聲明。考慮像'user_input','players_move',甚至只是'action'。兩個函數都可以安全地爲同一個角色使用相同的名稱,因爲單獨的函數使用不同的名稱空間。 –

回答

0

Python顯示你有錯誤的行。它可能是

consequence_0() = input ("Now you can see into darker places...") 

這是一個函數調用,你不能分配給函數調用。取出牛仔腿,你就會有,對於在較暗的地方

提示功能
def consequence_0(): 
    consequence_0 = input ("Now you can see into darker places...") 
    try: 
     if consequence_0 == 'shiny object': 
      print ("You picked up a key") 
     elif consequence_0 == 'pick up shiny object': 
      print ("You picked up a key") 
    except ValueError: 
     print ("You can't carry out that action") 
     print 
1

變化:consequence_0() = input ("Now you can see into darker places...")
這樣:consequence_0 = input ("Now you can see into darker places...")

而且也是這個 consequence_1() = input()consequence_1 = input()

在此代碼你正試圖將input的結果賦值給該函數,那是行不通的。你想把它分配給一個變量。

相關問題