Created
January 27, 2013 08:58
-
-
Save loriopatrick/4647468 to your computer and use it in GitHub Desktop.
A simple method to convert ISBN13 to ISBN10.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isbn_13_to_10 (isbn): | |
count = 0 | |
isbn = isbn[3:12] | |
for x in range(0, 9): | |
count += int(isbn[x]) * (10 - x) | |
z = (11 - (count % 11)) % 11 | |
if (z == 10): | |
z = 'X' | |
return isbn + str(z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment