I just can't figure out the problem. So i'm making a game and im using money to buy things in the game and this doesn't seem to be working. I try to write the new spent money in the .txt file and i just get an error.
with open("money.txt", "r") as rm:
game_money = rm.read()
with open("money.txt", "w") as fm:
fm.write(str(game_money))
def Function():
............
slowdown_price = 20
elif action == "buy_slowdown":
if game_money >= 20:
time.sleep(0.5)
game_money -= slowdown_price
slowdown_powerup += 1
with open("money.txt", "w") as wm:
wm.write(str(game_money))
I get the following error:
TypeError: unsupported operand type(s) for -=: 'str' and 'int'