1
isbn = []
for Count in range(1,14):
    ISBN = int(input("Please enter the next digit of ISBN: "))
    isbn.append(ISBN)

CalculatedDigit = 0
Count = 1
while Count < 14:
    CalculatedDigit = CalculatedDigit + isbn[Count]
    Count = Count + 1
    CalculatedDigit = CalculatedDigit + isbn[Count] * 3
    Count = Count + 1

while CalculatedDigit >= 10 :
     CalculatedDigit = CalculatedDigit - 10

CalculatedDigit = 10 - CalculatedDigit
if CalculatedDigit == 10:
    CalculatedDigit = 0

if CalculatedDigit == isbn[14]:
    print ("Valid ISBN")
else:
    print ("Invalid ISBN")
  1. インタープリターが「traceback (most recent call last): File "python", line 9, in IndexError: list index out of range」を返す
4

0 に答える 0