From 8a6d45ac6e54136714798ac49f9d05fc379c86fa Mon Sep 17 00:00:00 2001 From: Tithi Joshi Date: Thu, 5 Feb 2026 10:19:22 +0530 Subject: [PATCH 1/3] Improve isogram check by ignoring non-alphabetic characters Updated docstring to clarify isogram definition and added example with non-alphabetic characters. Modified letter extraction to ignore non-alphabetic characters. --- strings/is_isogram.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/strings/is_isogram.py b/strings/is_isogram.py index a9d9acc8138e..39ba62d936b5 100644 --- a/strings/is_isogram.py +++ b/strings/is_isogram.py @@ -5,26 +5,23 @@ def is_isogram(string: str) -> bool: """ - An isogram is a word in which no letter is repeated. - Examples of isograms are uncopyrightable and ambidextrously. + An isogram is a word or phrase in which no letter is repeated. + Non-alphabetic characters are ignored. + >>> is_isogram('Uncopyrightable') True >>> is_isogram('allowance') False + >>> is_isogram('six-year-old') + True >>> is_isogram('copy1') - Traceback (most recent call last): - ... - ValueError: String must only contain alphabetic characters. + True """ - if not all(x.isalpha() for x in string): - raise ValueError("String must only contain alphabetic characters.") - - letters = sorted(string.lower()) + letters = [char.lower() for char in string if char.isalpha()] return len(letters) == len(set(letters)) if __name__ == "__main__": input_str = input("Enter a string ").strip() - isogram = is_isogram(input_str) print(f"{input_str} is {'an' if isogram else 'not an'} isogram.") From 1fee3a873d79b0f6ac8f51918eed1c1c5520e24f Mon Sep 17 00:00:00 2001 From: Tithi Joshi Date: Thu, 5 Feb 2026 10:35:39 +0530 Subject: [PATCH 2/3] Fix formatting and add newline at end of file --- strings/is_isogram.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/strings/is_isogram.py b/strings/is_isogram.py index 39ba62d936b5..e1fd29dbbdb3 100644 --- a/strings/is_isogram.py +++ b/strings/is_isogram.py @@ -25,3 +25,5 @@ def is_isogram(string: str) -> bool: input_str = input("Enter a string ").strip() isogram = is_isogram(input_str) print(f"{input_str} is {'an' if isogram else 'not an'} isogram.") + + From 7b5013e5fbfe7f45af9e771192a29cd84c010292 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 05:08:25 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/is_isogram.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/strings/is_isogram.py b/strings/is_isogram.py index e1fd29dbbdb3..39ba62d936b5 100644 --- a/strings/is_isogram.py +++ b/strings/is_isogram.py @@ -25,5 +25,3 @@ def is_isogram(string: str) -> bool: input_str = input("Enter a string ").strip() isogram = is_isogram(input_str) print(f"{input_str} is {'an' if isogram else 'not an'} isogram.") - -