In the ISBN-10 (International Standard Book Numbering) system that was used until the end of 2006, each book is assigned a unique 10-digit code. The first nine digits uniquely identify the book itself, whereas the last digit merely serves as a check digit to detect invalid ISBN-10 codes.

ISBN
ISBN in text and barcode.

If $$x_1, \ldots, x_9$$ represent the first nine digits of an ISBN-10 code, the check digit $$x_{10}$$ is computed as \[x_{10} = (x_1+ 2x_2+ 3x_3+ 4x_4+ 5x_5+ 6x_6+ 7x_7+ 8x_8+ 9x_9)\!\!\!\!\mod{11}\] As a result, $$x_{10}$$ always takes a value in between 0 and 10. If the check digit is equal to 10, it is represented in the ISBN-10 code by the uppercase letter X. As such, only a single character is needed to represent the check digit.

Assignment

Write a function isISBN that takes a single argument. The function must return a Boolean value (bool) that indicates if the argument is a string (str) that represents a valid ISBN-10 code.

Note

The function needs to check explicitly if the argument passed to the function is a string (str). All arguments that are not strings are considered to be invalid ISBN-10 codes.

Preparation

The editor below (where you paste your solution for this assignment) contains a predefined skeleton of the solution. Read the section about doctests1 in the Python Standard Library to learn about test-driven development in Python and watch the video below to learn how to work with doctests. This will help you to understand the last three lines in the skeleton of the solution and the role played by the docstring we have included in the skeleton.

Example

>>> isISBN('9971502100')
True
>>> isISBN('9971502108')
False
>>> isISBN('53WKEFF2C')
False
>>> isISBN(4378580136)
False

Ask Pythia …

In the following instruction video, Pythia explains how to tackle this assignment. Watch this video as a stepping stone to solve other exercises about functions2.