Recently I began to study python, I have an idea to make an extremely primitive game. To accumulate a resource, gold is followed by a gradual increase, using a function with an infinite loop.
import time current_gold = 100 def gold(current_gold): while True: print(current_gold) time.sleep(1) current_gold += 10 gold(current_gold) current_gold -= 50 # test current_gold -= 50 # test How do I change current_gold in real time? Here you need to drive everything into the class or you need another function that will refer to the existing gold(current_gold) only with the argument gold(current_gold - 100) or how best to implement?