import random print("Welcome!") yes_no = input("Do you want to play? y/n ") rand_choice = random.randint(1,10) while yes_no == 'y': player_choice = \ input("Guess the number between 1 and 10: ") try: n = int(player_choice) except: print("Not a number!") break if n == rand_choice: print("You win! " "My number is also "+player_choice) break elif n < rand_choice: print("Your number is smaller.") else: # the player's number is bigger print("Your number is bigger.") yes_no = \ input("Do you want to try again? y/n ") print("Thank you for playing!")