0

Python

HST2: INTRODUCTION TO PROGRAMMING LAB Write a program that checks if a word supplied as the argument is an Isogram. An Isogram is a word in which no letter occurs more than once. Create a method 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'. My answer : def is_isogram(word) : if word is isogram: return ('word', True) else: return ('word', False) if word == "" : return( word, false) elif not word: Raise TypeError ("Argument should be a string") With my answer the code is till giving error, I need your help all

15th Feb 2017, 12:09 PM
Adigun Deborah
6 Answers
0
def is_isogram(word): if type(word) != str: raise TypeError('Argument should be a string') elif word == "": return (word, False) else: word = word.lower() for char in word: if word.count(char) > 1: return (word, False) return (word, True)
15th Feb 2017, 1:10 PM
Alexandra P
Alexandra P - avatar
0
@StarLord: why do you convert your set to a list ? it's not efficient and it is useless
21st Feb 2017, 9:43 PM
Amaras A
Amaras A - avatar
0
@StarLord: not really. But as it is at most 126 characters long, that's not a big deal...
22nd Feb 2017, 3:44 AM
Amaras A
Amaras A - avatar
0
I have tested it, all 3 tests passed but i cant submit cuz it doesent seem right somehow..
14th Mar 2017, 12:51 AM
Micheal Blake
Micheal Blake - avatar