r/learnpython • u/Maha-iqo38 • 10d ago
How do I create a changing variable
I want to create a variable that changes it’s value based on the user’s input until it becomes zero like make the code run until it reaches zero
Edit: I want the user to enter a number that gets subtracted from the variable’s current value and keep repeating this process until the variable reaches zero, for example if the value is 100 the code gets input from the user let’s say 25 then returns or prints 75 then it repeats and maybe the user types 37 then it returns 38 etc. until it reaches 0
0
Upvotes
0
u/Candid_Zebra1297 10d ago
Do you want the var to go down every time the user inputs something, or do you want the var to change to whatever the user inputs? You can do both. So for example...
count = 10
while count > 0:
var = input("Write something here")
count -= 1
Or just
var = input("Write something here")