#guess.go converted to python code import random import sys print("LET'S PLAY A GUESSING GAME! YOU WILL HAVE 10 GUESSES to GUESS A RANDOM NUMBER FROM 1 TO 100!\n") playAgain = True while playAgain: targetNum = random.randint(1,100) success = True for guesses in range(1,11): userguess = input("Enter guess #%d : " %(guesses)) try: guess = int(userguess) except: sys.exit("Your guess "+userguess+" is invalid!") if guess < targetNum: print("OOPS! Your guess %d is lesser than the random number!\n" %(guess)) success = False elif guess > targetNum: print("OOPS! Your guess %d is greater than the random number!\n" %(guess)) success = False elif guess == targetNum: print("Congratulations! You guessed the number!") success = True break if not success: print("Sorry, Game over! The random number is %d" %(targetNum)) repeat = '' while repeat != 'Y' and repeat != 'N': repeat = input("Do you want to play again ? (Y/N) : ") if repeat == 'N': playAgain = False print("Ok, thank you for playing. Goodbye!") if repeat == 'Y': playAgain = True print("Ok, here we go again!")