Sha256: 0175676885f569a794bef6382591728a4c64a3f7eb5ff2f8223130b012624f88

Contents?: true

Size: 313 Bytes

Versions: 87

Compression:

Stored size: 313 Bytes

Contents

def verify(isbn):
    chars = list(isbn.replace('-', ''))
    if chars and chars[-1] == 'X':
        chars[-1] = '10'
    if not len(chars) == 10 or not all(c.isdigit() for c in chars):
        return False
    indices = list(range(10, 0, -1))
    return sum(int(c) * i for c, i in zip(chars, indices)) % 11 == 0

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.179 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.178 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.177 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.176 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.175 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.174 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.173 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.172 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.171 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.170 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.169 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.167 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.166 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.165 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.164 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.163 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.162 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.161 tracks/python/exercises/isbn-verifier/example.py
trackler-2.2.1.160 tracks/python/exercises/isbn-verifier/example.py