TypeError:不支持的操作数类型 - :'str'和第4行的'str'如何修复

时间:2017-12-06 20:13:50

标签: python

print("you have chosen black")
gamble = input("how much do you want to gamble")
print("you have gambled",gamble)
money_left = money_left - gamble
print("you have",money_left,"left")
spin = random.randint(1,20)
print("It landed on....")
time.sleep(3)
print(spin)

第4行没有工作,money_left已经是变量

获取TypeError:不支持的操作数类型 - :'str'和'str'

1 个答案:

答案 0 :(得分:0)

将赌博投射到一个数字

money_left = int(money_left) - int(gamble)