Skip to content

Instantly share code, notes, and snippets.

@pratyushcrd
Created October 10, 2015 09:50
Show Gist options
  • Save pratyushcrd/ac6947bae8b69c72ed08 to your computer and use it in GitHub Desktop.
Save pratyushcrd/ac6947bae8b69c72ed08 to your computer and use it in GitHub Desktop.
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