Question: Help, My code is not working correcly with the console. i provided my works and console, please help me fixing my code. import random def

Help, My code is not working correcly with the console. i provided my works and console, please help me fixing my code. import random def display_title(): print("Guess the number!") print() def get_limit(): limit = int(input("Enter the upper limit for the range of numbers: ")) return limit def play_game(limit): number = random.randint(1, limit) print("I'm thinking of a number from 1 to " + str(limit) + " ") while True: guess = int(input("Your guess: ")) if guess < number: print("Too low.") count += 1 elif guess >= number: print("Too high.") count += 1 elif guess == number: print("You guessed it in " + str(count) + " tries. ") return  def main(): display_title() again = "y"  while again.lower() == "y": get_limit() play_game(limit) again = input("Play again? (y/n): ") print() print("Bye!") # if started as the main module, call the main function if __name__ == "__main__": main() 

Console

Guess the number!

Enter the upper limit for the range of numbers: 100 I'm thinking of a number from 1 to 100.

Your guess: 50 Too low. Your guess: 75 Too low. Your guess: 87 Too low. Your guess: 94 Too low. Your guess: 97 Too high. Your guess: 95 Too low. Your guess: 96 You guessed it in 7 tries.

Play again? (y/n): y

Enter the upper limit for the range of numbers: 10 I'm thinking of a number from 1 to 10.

Your guess: 5 Too low. Your guess: 7 Too low. Your guess: 9 Too low. Your guess: 10 You guessed it in 4 tries.

Play again? (y/n): n

Bye!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!