Answer the question
In order to leave comments, you need to log in
Why doesn't a simple python game work?
I launch the game through the console and nothing, even errors does not give out.
def game():
number = random.randint(0, 1000)
tries = 1
done = False
while not done:
guess = input('Введите число: ')
if guess.isdigit():
guess = int(guess)
if guess == number:
done = True
print('Ты победил! Я загадал {guess}. Ты использовал {tries} попыток.')
else:
tries += 1
if guess > number:
print('Загаданное число меньше!')
else:
print('Загаданное число больше!')
else:
print('Это не число от 1 до 1000!')
Answer the question
In order to leave comments, you need to log in
In order for the function to run, you need to call it:
def game():
number = random.randint(0, 1000)
tries = 1
done = False
while not done:
guess = input('Введите число: ')
if guess.isdigit():
guess = int(guess)
if guess == number:
done = True
print('Ты победил! Я загадал {guess}. Ты использовал {tries} попыток.')
else:
tries += 1
if guess > number:
print('Загаданное число меньше!')
else:
print('Загаданное число больше!')
else:
print('Это не число от 1 до 1000!')
game()
write at the end
if __name__=='__main__':
game()
game()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question