how to not give any output in python

124 views Asked by At

I am working on school problem where they give the equation for identifying if ISBN number is valid and give us ten inputs(numbers) and a stop input at the end.

This was my code:

a=str(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
g=int(input())
h=int(input())
i=int(input())
j=int(input())
u=input() #this is where stop is usually at
if j==int((int(a)+(2*b)+(3*c)+(4*d)+(5*e)+(6*f)+(7*g)+(8*h)+(9*i))%11):
    print("OK")
elif j!=int((int(a)+(2*b)+(3*c)+(4*d)+(5*e)+(6*f)+(7*g)+(8*h)+(9*i))%11):
    print("WRONG")
elif a=="stop":
    print("")

The last two lines are there because one of the answers was just one line input: "stop". In this case, the code shouldn't give any output but my code doesn't work and since there is only one input, it gives out an EOF on second line of the code. How can I make this work?

1

There are 1 answers

4
Julien On

j is either equal to int((int(a)+(2*b)+(3*c)+(4*d)+(5*e)+(6*f)+(7*g)+(8*h)+(9*i))%11) (which btw you don't have to compute twice...), or not. So elif a=="stop": is never reached. Test for a=="stop" first thing.