0

I require assistance with a bit of code, I'm practicing with something basic, I'm starting to understand concepts now but I still need much help, I've started with a random number generator and I'd like for it to allow you to guess again until correct.

import random

hidden = random.randrange(1, 201)
print(hidden)

guess = int(input("Please enter your guess:"))

if guess == hidden:
    print("Hit!")
elif guess < hidden:
    print("Your guess is too low")
else:
    print("Your guess is too high")

Thanks, R

  • put the code in a `while True` loop (above your `guess =` line) and add a `break` statement underneath `print("Hit!")`. – Thymen Dec 29 '20 at 19:08
  • Does this help [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – itprorh66 Dec 29 '20 at 19:57
  • Thank you for your help guys, much appreciated. – I_am_Roshi Dec 30 '20 at 11:41

0 Answers0