Решите задачу на Python(новичок)
я попытался создать игру в угадайку :
from random import randrange user_name = input("Hello user, please input your name : ") print("Hello " + user_name + " Welcome to the random number guessing game.\n" "here we will generate a number from 1 to 20\n" "and you will have to guess the number\n" "dont worry, we will help you through ;) ") out_of_guesses = False guess_limit=5 guess_count=0 if guess_count == guess_limit: out_of_guesses= True secret_number = int(randrange(20)) answer = int(input("choose a number: ")) while str(secret_number) > str(answer) and not(out_of_guesses): print("your number is bigger than the answer") guess_count += 1 print("you have left " + str(guess_count) + " / " + str(guess_limit) + " guesses") answer = input("take another guess: ") while str(secret_number) < str(answer) and not(out_of_guesses): print("your number is lower than the answer") guess_count += 1 print("you have left " + str(guess_count) + " / " + str(guess_limit) + " guesses") answer = input("take another guess: ") if secret_number == answer: print("You Won, the number is: " + str(secret_number)) if out_of_guesses: print("You are out of Guesses")
Что я уже пробовал:
по какой-то причине он разрывает петлю,
ну, у меня мало ошибок.
пожалуйста, не смейтесь, я программирую примерно 3 дня.