要從變量「glory」中取1,變量需要是整數。當它變成一個整數時,我只會收到:「無法分配函數調用」。無法爲函數調用或不支持操作數類型爲 - =:'str'和'int'
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(glory) - = 1'做什麼? –
從榮耀中取出1 – FynFTW
int(glory)用參數glory調用函數int,它可能會返回一個整數然後你試圖做一些像'10 - = 1',這沒有任何意義 –