@shinka

Как ограничить ввод до 10.000?

Мне надо написать программу, основную ее идею я сделал, но мне надо ограничить ввод до 10.000. Это мне надо сделать без if, while и т.д

Питон 3.7.0

Вот код(я сделал с if, а надо без, помогите)
n = int(input());
c = n-1;
a = n+1;
if n > 10000:
print(‘Error, the entered number exceeded the limit’)
else:

print («The next number for the number», n, «is», a, )
print(«The previous number for the number», n, «is», c)
  • Вопрос задан
  • 5941 просмотр
Пригласить эксперта
Ответы на вопрос 2
@deliro
n = min(int(input()), 10_000)
Ответ написан
@Warlodya
n = int(input("Enter number:"))
c = n-1
a = n+1
exceptionLine="Error, the entered number exceeded the limit"
outputLine="The next number for the number "+str(n)+" is "+ str(a)+ "\n The previous number for the number "+ str(n)+ " is "+ str(c) 
n_type = (outputLine, exceptionLine)
print(n_type[n>10000])
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы