+ 5
isogram
Create a method using Python 2.7.x syntax called is_isogram that takes one argument, a word to test if it's an isogram. This method should return a tuple of the word and a boolean indicating whether it is an isogram. If the argument supplied is an empty string, return the argument and False: (argument, False). If the argument supplied is not a string, raise a TypeError with the message 'Argument should be a string'. Example: is_isogram("abolishment") Expected result: ("abolishment", True)
8 Answers
+ 11
https://code.sololearn.com/cFCaK0ABUesm/?ref=app
+ 7
I guess this one is more obedient to the challenge rules 😁
def is_isogram(word):
if not isinstance(word, str):
raise TypeError('Argument should be a string.')
elif not len(word):
return word, False
else:
return word, len(word) == len(set(word))
https://code.sololearn.com/cwN0r52NBek9/?ref=app
+ 6
https://code.sololearn.com/cx7c5P130s4H/?ref=app
I know easier ways but come on, this is a unique solution :) and easy to understand
+ 3
Okay what is an isogram?
+ 2
"nonpattern word" a word or phrase which does not repeat same letters
0
def is_isogram(string):
# convert the input string to a set
# a set only contains unique elements, so if the length of the set is the same as the length of the input string, there are no repeating letters
return len(set(string)) == len(string)
print(is_isogram("turbulence")) # should print "false"