tgoop.com/tsmfuture/16
Create:
Last Update:
Last Update:
import random
def guess_the_number():
number = random.randint(1, 20)
guess = 0
count = 0
invalid_attempts = 0
while guess != number:
guess_input = input("Guess the number between 1 and 20 (or type 'I don't know' to see the answer): ")
if guess_input.lower() == "i don't know":
print(f"The number was {number}.")
break
try:
guess = int(guess_input)
count += 1
invalid_attempts = 0
if guess < number:
print("Your guess is too low.")
elif guess > number:
print("Your guess is too high.")
except ValueError:
invalid_attempts += 1
print("Please enter a valid number or 'I don't know'.")
if invalid_attempts == 3:
print("Too many invalid attempts. The game is over.")
break
if guess == number:
print(f"Congratulations! You guessed the number in {count} attempts.")
#شروع بازی
guess_the_number()
جهت ارتباط با دنیای تی اس ام.آینده فقط کافیه روی این متون آبی لمس کنی😍💥
Telegram| instagram| GitHub| linkedin
BY tsm.future
Share with your friend now:
tgoop.com/tsmfuture/16