Untitled
unknown
python
a year ago
592 B
3
Indexable
import random
if __name__ == '__main__':
number = random.randint(1, 9)
guess = 0
attempts = 0
while True:
guess = input("Enter a guess between 1 to 9 or exit: ")
if guess == "exit":
break
guess = int(guess)
attempts += 1
if guess < number:
print("Too low")
elif guess > number:
print("Too high")
else:
print("Right!")
print(f"You took only {attempts} attempts!")
number = random.randint(1, 9)
attempts = 0
Editor is loading...
Leave a Comment