Untitled
unknown
python
a year ago
426 B
4
Indexable
def is_valid(isbn): isbn = isbn.replace("-", "") if len(isbn) != 10 or (isbn[-1] != "X" and not isbn[-1].isnumeric()): return False check = isbn[-1] if check == "X": check = 10 sum = 0 for i, digit in enumerate(isbn[:-1]): if not digit.isnumeric(): return False sum += int(digit) * (10 - i) return True if ((sum + int(check)) % 11) == 0 else False
Editor is loading...
Leave a Comment