This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to import random module | |
import random | |
# to create a range of random numbers between 1-10 | |
n = random.randrange(1,100) | |
# to take a user input to enter a number | |
guess = int(input("Enter any number: ")) | |
while n!= guess: # means if n is not equal to the input guess | |
# if guess is smaller than n | |
if guess < n: | |
print("Too low") | |
# to again ask for input | |
guess = int(input("Enter number again: ")) | |
# if guess is greater than n | |
elif guess > n: | |
print("Too high!") | |
# to again ask for the user input | |
guess = int(input("Enter number again: ")) | |
# if guess gets equals to n terminate the while loop | |
else: | |
break | |
print("you guessed it right!!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment