Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
How do I use python to alert me when it is time to cut my bread?
I was inspired going through the course with an idea for a simple program. When you make bread you're supposed to wait a while before cutting it. I might have 10 different loaves made at different times. Each needs to cool for an hour and a half. How would I tell python to keep track of my breads and tell me when it is time to cut the bread? Sorry if this is a stupid question. Just curious how difficult this would be. Thank you for your time.
Steven Parker229,005 Points
You have a few options, one would be to use the datetime module and sample the current time in a loop until the time you need to ring the bell occurs.
Another is to just pause execution for the amount of time you want to wait before ringing, using the sleep function of the time module.
There are several ways to make a sound, but if you use a Windows machine you might want the winsound module.
Thanks, Steven. I'm experimenting with that right now. This appears to work on a small scale. But here's the thing. I need it to iterate over an ever expanding list of bread. I making bread 12 hours a day at various times throughout the day. I want to be able to add something periodically to the program. How would I set that up in a loop? Maybe I could nest one loop inside another loop to check if anything has been added?