Validate and Convert ISBNs

easy
Unit 6 · Decimal & Validation0/3 to milestone

Implement:

  • valid_isbn10(s): 10 characters after removing hyphens; the first 9 are digits and the last is a digit or X (= 10); valid if ∑i=110i⋅di\sum_{i=1}^{10} i \cdot d_i (weights 10 down to 1) is divisible by 11
  • valid_isbn13(s): 13 digits after removing hyphens; weights alternate 1, 3, 1, 3...; valid if the sum is divisible by 10
  • isbn10_to_13(s): prefix 978 to the first 9 digits of a valid ISBN-10 and append the correct ISBN-13 check digit (return the 13-digit string without hyphens)
#validation#strings2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Validate and Convert ISBNs · TechGradify