Guess the number in 10 tries

Guess the number in 10 tries - student project

import sys
import random

upper = 50
specialNum = random.randint(1,upper)


print("""The computer has randomly chosen a special number between 1 and""", upper,""".
Try to guess the special number within 10 tries. Each try the program will tell
whether your guess is higher or lower than the special number! OK let's get this
party started!""", end = '\n')

userTry = 0


guessLeft = 10


while userTry < 10:


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


    if guess > upper:
        print("Special number is between 1 and 50. Please try again.", guessLeft, "more guesses left.")
        continue 

     
    guessLeft = 10 - (userTry + 1)

 

    if guess < specialNum:
        print("Your guess is lower than special num.", guessLeft, "more guesses left.")

   

    elif guess > specialNum:
        print("Your guess is higher than special num.", guessLeft, "more guesses left.")


    else:
        print("Congratulations! You got it.", guess, "was the special number!")
        sys.exit()


    userTry += 1

 

print("Too bad too sad! Better luck next time.")