2016-11-05 9 views
2

if、else whileループを使用せずにA、B、またはCの変数を 'remove'で減算しようとしていますが、それは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オブジェクトになります。タイプキャストする必要がある場合は、次のような別のステートメントでそれを実行する必要があります。

関連する問題