-
-
Save pratyushcrd/ac6947bae8b69c72ed08 to your computer and use it in GitHub Desktop.
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
import random | |
num = random.randrange(0, 10) | |
while True: | |
str = input("guess between 0 to 9 or type exit ") | |
if str == "exit": | |
break | |
if not(str.isalnum()): | |
print("not a valid input ") | |
continue | |
str = int(str) | |
if str == num: | |
print("you guessed correctly ") | |
break | |
elif str > num: | |
print("you guessed too high ") | |
else: | |
print("you guessed too low ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment