+ 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)

28th Nov 2017, 3:34 PM
Franklin Yaw Frimpong
Franklin Yaw Frimpong - avatar
8 ответов
29th Nov 2017, 4:03 AM
David Ashton
David Ashton - avatar
+ 11
https://code.sololearn.com/cFCaK0ABUesm/?ref=app
28th Nov 2017, 6:48 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
29th Nov 2017, 2:35 PM
David Akhihiero
David Akhihiero - avatar
+ 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
29th Nov 2017, 5:03 AM
David Ashton
David Ashton - avatar
+ 6
https://code.sololearn.com/cx7c5P130s4H/?ref=app I know easier ways but come on, this is a unique solution :) and easy to understand
29th Nov 2017, 4:07 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
Okay what is an isogram?
28th Nov 2017, 3:38 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
"nonpattern word" a word or phrase which does not repeat same letters
28th Nov 2017, 3:58 PM
Franklin Yaw Frimpong
Franklin Yaw Frimpong - avatar
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"
28th Jan 2023, 11:44 PM
Buchi