Skip to content

Instantly share code, notes, and snippets.

@vikychoi
Created November 6, 2017 06:12
Show Gist options
  • Save vikychoi/224585beb44bc55c39389065a2f12177 to your computer and use it in GitHub Desktop.
Save vikychoi/224585beb44bc55c39389065a2f12177 to your computer and use it in GitHub Desktop.
import random
number = random.randint(1,9)
print("type exit to leave")
attempt = 1
while True:
guess = input("please guess a number from 1 to 9")
if guess != "exit":
guess = int(guess)
else:
break
if guess > number:
print(" Too high")
attempt = attempt + 1
elif guess < number:
print(" Too low")
attempt = attempt + 1
else:
print("bingo")
print(" u have guessed ", attempt, " of times")
number = random.randint(1,9)
attempt = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment