Created
June 19, 2018 14:21
-
-
Save iswarup/da09653543047d5fb21cc30149857381 to your computer and use it in GitHub Desktop.
Guessing game I.
This file contains hidden or 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 | |
number= random.randint(1,9) | |
count= 0 | |
guess= 0 | |
while guess != number: | |
guess= input("Guess the number or type exit to exit. ") | |
if guess == "exit": | |
break | |
if int(guess) > number: | |
print("Too high") | |
elif int(guess) < number: | |
print("Too low") | |
else: | |
print("Correct!") | |
print("Guess the number again to continue the game else type exit.") | |
count+=1 | |
print("You attempted",count,"times.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment