I
I
Ivan2014-11-11 12:41:00
Python
Ivan, 2014-11-11 12:41:00

How to correctly formulate an exception?

How to correctly formulate an exception when it is necessary that the value be given in all cases except those that end in 11

a=int(input())
if a==1:
    print(a, 'программист')
b=a%10
c=a%100
if (b==1 and (c!=11)):
    print(a, 'программист')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Scherbakov, 2014-11-11
@muller_johann

Maybe you should not turn the input number into int. Let there be a line. You can then write s.endswith('11').

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question