Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions isbn-verifier/isbn_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ def formatted_isbn(isbn: str) -> list[int]:
for char in isbn:
if char.isdigit():
result.append(int(char))
if isbn[-1].lower() == "x":
if isbn[-1] == "X":
result.append(10)

print(f"result: {result}, len: {len(result)}")
return result


Expand All @@ -48,6 +46,7 @@ def is_valid(isbn: str) -> bool:
:return: Tru if isbn is valid, False otherwise
"""
# Non ISBN chars or empty strings not allowed
isbn = isbn.upper()
if not all(char in ISBN for char in isbn.replace("-", "")) or not isbn:
return False
# In case X is present, it should be at the end of the string only
Expand Down