I am a newbie and need help to include a "last try" phrase after 4 of the 5 tries and a try-except element. I searched through past questions but I am still stuck with this code:
import random
random_number = random.randrange(0,20)
print(random_number)
print("Guess a number in the range 0-20. You have five tries.")
guess = False
while guess == False:
user_input = int(input("Your guess? "))
if user_input == random_number:
guess = True
print("Congratulations! Your guess is correct! It is " + str(random_number) + "!")
elif user_input > random_number:
print("The number is too high.")
elif user_input < random_number:
print("The number is too low.")
elif user_input < 5:
try:
guess = int(input("This is your last guess: "))
except ValueError:
print("Sorry. Your guesses are incorrect. The right answer is " + str(random_number) + ".")
print("End of program")