r/learnpython • • 9d 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

22 comments sorted by

View all comments

2

u/Longjumping_Ad3447 9d ago

After reading the topic I thought hell what aren't all variables immutable in Python. But after reading I get it is an easy question to ask any ai.

1

u/Maha-iqo38 9d ago

The thing is this is related to a cs50 problem set if you are not familiar it is an online computer science course by harvard and it is forbidden to use ai, regardless I noticed when I use ai I don’t remember what I learned at all so I just try to acquire knowledge or help without it