Python Random Number, Generate random number from 1 to 100
number = random.randint(1, 100)
Provide the number through input
guess = int(input("Guess the number between 1 and 100: "))
Now try to compare the given number
if guess < number: print("Too low") guess = int(input("Guess again: "))
if the number is greater than guess
elif guess > number: print("Too high") guess = int(input("Guess again: "))
Python Random Number
import random number = random.randint(1, 100) guess = int(input("Guess the number between 1 and 100: ")) while guess != number: if guess < number: print("Too low") guess = int(input("Guess again: ")) elif guess > number: print("Too high") guess = int(input("Guess again: ")) print("Congratulations! You guessed the number correctly!")