Python:
from random import randint
import sys
def guess_user():
p_steps = 0
a = randint(1, 100)
while True:
answer = input(f'Is it: ')
p_steps += 1
if answer == "exit":
exit(main())
elif int(answer) < a:
print('greater')
elif int(answer) > a:
print("less")
elif int(answer) == a:
print("you guessed!")
break
print(f'Got it in {p_steps} steps')
return p_steps
guess_user()
print(p_steps)
Последнее редактирование модератором: