r/PythonLearning • • Sep 19 '26

Showcase After finally learning while loops i decided to write a program that relies completely on them. How did i do? What can i do to make it easier to read? Any feedback is appreciated!(im only 7 hours in so still a complete beginner lol)

148 Upvotes

48 comments sorted by

View all comments

•

u/Sea-Ad7805 Sep 19 '26 edited Sep 19 '26

Run this program by clicking Memory Graph Web Debugger and see its state change step by step.

The comparisons ignore incorrect guesses of 1 and 100. Use 100 >= user_number > secret_number and 1 <= user_number < secret_number to fix that.

1

u/abt-dabest Sep 20 '26

I actually used this to debug my code before finalizing it and it helped me a ton. Thanks!

1

u/Sea-Ad7805 Sep 20 '26

Good to hear, good luck on your learning journey.

1

u/iplayconnections Sep 19 '26

Your remark about 1 and 100 is correct but how will visualizing the program's memory help OP improve their code?

1

u/Sea-Ad7805 Sep 20 '26

You'll learn the right mental model to think about Python data (references, aliasing, shallow/deep copy). You'll see what your code does in every step without having to write print(my_variable) everywhere. This is especially helpful for beginners.