Nov-14-2018, 12:09 AM
I'm trying to run this code & keep getting a 'Time Limit Exceeded' Error when trying to run it.
Could it be the online IDE that I am using, or are the instructions in my code more complex than it should be?
I'm currently still getting my feet wet with Programming and only have a little bit over a week of experience
under my belt. Any and all advice is welcome.
Could it be the online IDE that I am using, or are the instructions in my code more complex than it should be?
I'm currently still getting my feet wet with Programming and only have a little bit over a week of experience
under my belt. Any and all advice is welcome.
import random # Automated Number Guessing Game. # Commented out code and edited it so it doesn't take user input # And instead generates a random number to guess automatically def startGame(): print("Welcome to the Game") #name = input('Please enter your name: ') #print('Hello ' + name, end='. ') print("I am thinking of a number between 1 - 10") secretnumber = random.randint(1, 9) for i in range(3, -1, -1): print("Guess The Number: ") guess = random.randint(1, 9) if guess < secretnumber and i > 0: print("Your Guess: " + str(guess)) print(str(i) + ' Guesses left.') print("Guess Higher") elif guess > secretnumber and i > 0: print("Your Guess: " + str(guess)) print(str(i) + ' Guesses left.') print("Guess Lower") else: break if guess == secretnumber: print("Your Guess: " + str(guess)) print("You got it Correct") else: print("Your Guess: " + str(guess)) print('Aw, your out of Guesses') #print('Aw ' + name + ', your out of Guesses.') startGame()