Last active
April 11, 2017 19:54
-
-
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.
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_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")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks@Jerry hopefully this will help