Skip to content
Sign upLog in
Number Guessing Game
Profile icon

Hi this is a very simple game, the user guesses a number between 1-20 and is told if it is too high or low. If anyone has an idea that I (a python beginner) can do or suggestions to make this better please tell me. Thanks

You are viewing a single comment. View All
Profile icon

Hey I remember when I did this a while back and somethings that can be really nice when working with users are making sure no matter what they type the program will not crash.
This can be done using a try: block before using int(input so that things will run smoother if accidently type a letter. Using a try block with a while statement is usually the best approach.(actually it might not be that is just how i do it)
something else that would be nice is adding a colon and a space at the end of an input statement. like guess=int(input('Try again: '))
If you can also print("") in places that need spaces as this makes more sense. This can be after Too high.
Lastly adding a way to say hey I want to play this game x number of times and then add a scoreboard for each time you play that is simple like hey you took 10 try which is 3 better than your last attempt. And then at the end average all the numbers and say hey it takes you average 5 times to solve this puzzle.

Profile icon

I started one of the improvments I talked about. If you like you could implement the others. Here is the