So i have this code:
from random import randint
for i in range(9999999):
a=input("press any key to roll the wheel: ")
money=0
money2=randint(0, 400)
money+=money2
print(money)
And while i was testing the program, i found that it isn’t doing what i expected it to do (for example: add 382 with 196), i wanna ask, whats wrong? Everything looks to be working just fine, just that it seems to change the "money" variable temporarily, after that it resets. What happens when you press enter multiple times
>Solution :
You keep setting money to 0 in the loop. Do this:
from random import randint
money=0
while True:
a=input("press any key to roll the wheel: ")
money2=randint(0, 400)
money+=money2
print(money)
It’s better to use while True as well.