Created
July 20, 2020 09:25
-
-
Save kseistrup/367298c2d4319aa01e9efc13230357a0 to your computer and use it in GitHub Desktop.
Test if TEXT is an isogram, using Python
This file contains 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 is_isogram(text, case_sensitive=False): | |
"""Test if TEXT is an isogram""" | |
if type(text) is not str: | |
return False | |
if not text: | |
return True | |
unique = set(text if case_sensitive else text.casefold()) | |
return len(text) == len(unique) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment