I'm using this example ISBN: 0199160503
I know it's not great at the moment, but for not, I just want it to work.
I've checked the calculations over and over, and CheckDigit10 DOES equal CheckingCheckDigit at the final part (hence the overuse of print statements...), and yet it still comes out as an invalid ISBN.
Can someone please help? I'm not too advanced at coding, so it could be a super simple error that I'm not seeing.
print("You will be asked to enter an ISBN-10 Number. Please enter it digit by digit.")
ISBN10NumberList = []
ISBN10NumberAdder = 0
for count in range (10):
if (count <= 8):
ISBN10NumberList.append(int(input("Please enter the ISBN digit: ")))
elif (count == 9):
CheckDigit10 = input("Please enter the ISBN digit: ")
print("CheckDigit: ", CheckDigit10)
if CheckDigit10 == "X" or CheckDigit10 == "x":
CheckDigit10 = 10
print("CheckDigit: ", CheckDigit10)
for count in range (0, 9):
ISBN10NumberAdder += int(ISBN10NumberList[count]) * (10 - count)
print(ISBN10NumberAdder)
CheckingCheckDigit = ISBN10NumberAdder % 11
print("CheckingCheckDigit after mod 11:",CheckingCheckDigit)
CheckingCheckDigit = 11 - CheckingCheckDigit
print("CheckingCheckDigit final:",CheckingCheckDigit)
print("CheckDigit: ", CheckDigit10)
if (CheckDigit10 == CheckingCheckDigit):
print("This is a valid ISBN!")
else:
print("This is not a valid ISBN!")