Skip to content

Instantly share code, notes, and snippets.

@iswarup
Created June 19, 2018 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iswarup/da09653543047d5fb21cc30149857381 to your computer and use it in GitHub Desktop.
Save iswarup/da09653543047d5fb21cc30149857381 to your computer and use it in GitHub Desktop.
Guessing game I.
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