Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 获取错误&x27;SyntaxError:can';t分配给函数调用';_Python 2.7_While Loop - Fatal编程技术网

Python 2.7 获取错误&x27;SyntaxError:can';t分配给函数调用';

Python 2.7 获取错误&x27;SyntaxError:can';t分配给函数调用';,python-2.7,while-loop,Python 2.7,While Loop,我试图从A、B或C中减去'remove'变量中的值,而不在while循环中使用if…else,但这会导致第9行出现语法错误。这背后的原因是什么 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 pi

我试图从A、B或C中减去'remove'变量中的值,而不在while循环中使用if…else,但这会导致第9行出现语法错误。这背后的原因是什么

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
更改int(选择_桩)以选择_桩

choose_pile = int(choose_pile)-remove
变量
choose\u pile
将是一个int对象。如果需要对其进行打字,则必须使用不同的语句,例如:

x = int(x)