Answer:
try:
from random import randint
except:
x=5
x=randint(1, 20)
numGuesses, userGuess, secretNum = 0, 0, x
name = str(input("Hello! What is your name? "))
while True:
numGuesses+=1
userGuess=int(input("Guess a number from 1 to 20: "))
if userGuess < secretNum:
print("Too low, try again.")
elif userGuess > secretNum:
print("Too high, try again.")
else:
break
print("The number was "+str(secretNum)+", and " + name + " guessed it in "+str(numGuesses)+" guesses!")