2

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!")
electricbl00
  • 45
  • 1
  • 5
  • 1
    You need to explicitly make the user's input an integer, e.g. `'9' != 9`. – jonrsharpe Jan 29 '15 at 19:47
  • Thank you so much! Fixed it! – electricbl00 Jan 29 '15 at 19:50
  • 2
    @jonrsharpe Make your comment an Answer so the question can be solved. – mbomb007 Jan 29 '15 at 19:52
  • @mbomb007 this should be closed as a duplicate of any one of a million other "why doesn't the user input match something that isn't a string" questions, not solved – jonrsharpe Jan 29 '15 at 20:30
  • @jonrsharpe Even questions that are marked as duplicate can have their own answers. If you won't make it an answer, I will. The question was NOT asking that specific question, so it's not a duplicate, anyway. – mbomb007 Jan 29 '15 at 20:32

0 Answers0