Skip to content
Advertisement

Tag: infinite-loop

Python: vending machine

The program offers items, has the user pay for items, gives the items, and updates the stock of each item. It seems to work more or less. I have 2 questions: I don’t know how to exit the vending machine program after the user answers “n” to “buy something else? (y/n): “. Is there a way to make the code

How to stop an infinite loop safely in Python?

I’ve got a script that runs an infinite loop and adds things to a database and does things that I can’t just stop halfway through, so I can’t just press Ctrl+C and stop it. I want to be able to somehow stop a while loop, but let it finish it’s last iteration before it stops. Let me clarify: My code

Advertisement