无法将函数分配给 -= 的调用或不支持的操作数类型:'str' 和 'int'

Can't assign function to call or unsupported operand type(s) for -=: 'str' and 'int'

要从变量"glory"中取1,变量需要是整数。当把它变成一个整数时,我刚收到:"Can't assign function to call".

import sys

glory = input("Glory charge: ")
glory_prev = glory
print(glory_prev)
pouch = 28
run_num = 0
nat_price = input("Nat price: ")

while True:
    run = input("You've done " + (str(run_num)) + " runs: ")
    if run == "a":
        (int(glory) -= 1
        pouch -= 1
        if glory == 0:
            print("New glory needed")
            glory = glory_prev
        if pouch == 0:
            print("Repair pouch")
            pouch = 28

    elif run == "q":
        sys.exit
    else:
        continue

请帮忙,谢谢。

您唯一需要考虑的是删除 int of glory 之前的括号并将该 glory 语法更改为

glory = int(glory) - 1

所以代码会是这样

import sys

glory = input("Glory charge: ")
glory_prev = glory
print(glory_prev)
pouch = 28
run_num = 0
nat_price = input("Nat price: ")

while True:
    run = input("You've done " + (str(run_num)) + " runs: ")
    if run == "a":
        glory = glory - 1
        pouch -= 1
        if glory == 0:
            print("New glory needed")
            glory = glory_prev
        if pouch == 0:
            print("Repair pouch")
            pouch = 28

    elif run == "q":
        sys.exit
    else:
        continue