-
-
Save vikychoi/224585beb44bc55c39389065a2f12177 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 | |
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