Skip to content

Instantly share code, notes, and snippets.

@kseistrup
Created July 20, 2020 09:25
Show Gist options
  • Save kseistrup/367298c2d4319aa01e9efc13230357a0 to your computer and use it in GitHub Desktop.
Save kseistrup/367298c2d4319aa01e9efc13230357a0 to your computer and use it in GitHub Desktop.
Test if TEXT is an isogram, using Python
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