Answer the question
In order to leave comments, you need to log in
Why does an already suppressed condition end up in else?
a=int(input())
if a==1:
print(a, 'программист')
b=a%10
c=a%100
if (b==1 and (not c==11) and (not a==1)):
print(a, 'программист')
if((b==2 or b==3 or b==4) and (not(c==12 or c==13 or c==14))):
print(a, 'программиста')
else:
print(a, 'программистов')
Answer the question
In order to leave comments, you need to log in
The first if has no else. All the following checks are performed with a=1 in the usual way. In such cases, it is convenient to use the abbreviation else if - elif
a = int(input())
b = a % 10
c = a % 100
if a == 1:
print(a, 'программист')
elif (b == 1 and not c == 11 and not a == 1):
print(a, 'программист')
elif((b == 2 or b == 3 or b == 4) and not(c == 12 or c == 13 or c == 14)):
print(a, 'программиста')
else:
print(a, 'программистов')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question