2016-11-05 45 views
2

我試圖從A,B或C中刪除'remove'變量中的值,而不使用if ... else while while循環,但它會拋出第9行的語法錯誤。背後的原因是什麼?獲取錯誤'SyntaxError:無法分配給函數調用'

print "\t\t\t\t\t Welcome to the game of piles" 
A=3 
B=3 
C=3 
print "A: %d\t B: %d\t C: %d" %(A,B,C) 
while A>0 and B>0 and C>0: 
    choose_pile = raw_input("\nChoose a pile: ") 
    remove = input("How many to remove from pile %s" %choose_pile) 
    int(choose_pile)=int(choose_pile)-remove 

回答

0

將int(choose_pile)更改爲choose_pile。

choose_pile = int(choose_pile)-remove 

變量choose_pile將是一個int對象。如果你需要對它進行類型轉換,那麼你將不得不在不同的陳述中這樣做,例如:

x = int(x) 
相關問題