def verify_isbn(isbn): '''verify_isbn(str) - > boolean Returns True if the given ISBN string is valid.''' if ( type(isbn) != str ): #return False raise Exception("Parameter given not of type string") isbn = isbn.replace('-', '') # Ignoring dashes is fun # Check for ISBN-10 Format if ( len(isbn) != 10 ): #return False raise Exception("Parameter given not a proper 10 digit ISBN") sum = 0 count = 10 for digit in isbn[0:-1]: sum += int(digit) * count count -= 1 sum = (11 - (sum % 11)) % 11 if ( sum == 10 ): return "X" == isbn[-1] else: return str(sum) == isbn[-1]