+ 1

Need help

Can someone help me make a isogram detector I feel like I'm close but can't figure it out? word = str(input()) iso = "abcdefghijklmnopqrstuvwxyz" if sorted(word) >= sorted(iso): print("false") else: print("true")

31st Aug 2023, 3:04 AM
Marshall Lance Freeman
Marshall Lance Freeman - avatar
2 ответов
+ 7
Marshall Lance Freeman , you are not far away from a solution. see your code with some comments and hints: word = str(input()) # we do not need to convert input to string, input() returns string as default # iso = "abcdefghijklmnopqrstuvwxyz" # not required # >>> what is an isogram: a string is called an isogram if it only contains unique characters, no duplicates. #if sorted(word) >= sorted(iso): this is not applicable to the task description. # we need to check if there are duplicated characters in the input. this can be done by using a set. set can not hold duplicared characters, so "hello" will be "helo" as a set. # you can compare the length of the original input string against the input string converted as set. # if length of both is equal => input is an isogram. if length is different, input is not an isogram print("false") else: print("true")
31st Aug 2023, 1:39 PM
Lothar
Lothar - avatar
+ 6
Sreeju , sorry to say, but your suggested code does fail for all test cases when running it in code coach.
31st Aug 2023, 1:46 PM
Lothar
Lothar - avatar