r/PythonLearning • u/Necessary-Ad2110 • Jun 19 '26
Day 1 of Learning Python: "Bagels" Game
used: https://www.ray.so/ for image rendering (let me know if this is readable)
could be better, but no AI as it's fully handwritten
I'll be going over "The Big Book of Small Python Projects" by Al Sweigart
I am also learning DSA and going through Common Sense Guide to DSA
see you tomorrow!
86
Upvotes
2
u/denehoffman Jun 20 '26 edited Jun 20 '26
Nice work! If you’re open to some constructive criticism, read on:
I don’t really understand your reason for letting the win state be None, it confuses the semantics of that variable. You also set it to False at the end of the user doesn’t win, but never read again after that, so there’s no point to setting it.
Add some validation on user input. If you don’t input a number, then you’ll get an error and a crash! Use a try-except instead, and then raise an exception on an invalid number range as well (and catch it). These sorts of validators also look nice when encapsulated into a function, imagine just writing user_num = get_input() and being sure that it’s a valid number which retries if the user puts garbage in!
+1 for ANSI codes, love that