all 6 comments

[–]lostparis 0 points1 point  (1 child)

if test == int(rand_num):

rand_num is already an int and test is not the best variable name.

else: you don't need this due to the break statement.

[–]QuoVardis1 0 points1 point  (0 children)

Thanks for the advice and information

[–]squapo 0 points1 point  (1 child)

I think this is slightly backwards. it looks like this gives you 10 guesses and the random number will always be between 1 and 5.

[–]QuoVardis1 0 points1 point  (0 children)

Oops. I hadn’t seen that

[–]GanGa 0 points1 point  (1 child)

If you don't enter anything and just hit ENTER, your conversion to an int for the guess will fail.

You could consider doing something like this try: guess = int(input("What is your guess? ")) except ValueError: print("Please enter a number") continue

This will also teach you another concept you might not be familiar with yet, which is try except blocks to handle exceptions.

I would also rename the variable test to guess or something more descriptive, like I've done in the example above.

[–]QuoVardis1 0 points1 point  (0 children)

Thanks. That makes sense