Skip to content

Instantly share code, notes, and snippets.

@jerryOkafor
Last active April 11, 2017 19:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerryOkafor/cef9a27374cbc2c20b97ec413a8aa8ef to your computer and use it in GitHub Desktop.
Save jerryOkafor/cef9a27374cbc2c20b97ec413a8aa8ef to your computer and use it in GitHub Desktop.
A function that check if a word is an Isogram, returns the boolean indicator and the turple of the word, raise a TyepError if the argument is not a string with a message "Argument should be a string", returns the argument and false if the argument is empty.
def is_iso(word):
if not type(word) is str:
raise TypeError("Argument should be a string")
if len(word) == 0:
return word, False
word = word.lower()
for char in word:
if word.count(char) > 1:
return tuple(word), False
return tuple(word), True
print(is_iso("subdermatoglyphic"))
print(is_iso("uncopyrightables"))
print(is_iso("ambidextrously"))
print(is_iso("Goods"))
print(is_iso("Effort"))
print(is_iso("Moose"))
@okoro056
Copy link

Thanks@Jerry hopefully this will help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment