0

Isogram detector

Hi, The code for an isogram detector (each letter only once) passes 3 out of 5 test cases. Something seems to be wrong with my code. Maybe something about the count function? https://code.sololearn.com/cfnkVQDYfZcu/?ref=app

11th Aug 2022, 4:31 PM
Sonja
6 Answers
0
input = input() count = 0 for i in input: count += input.count(i) if count > len(input): print("false") else: print("true")
12th Aug 2022, 11:34 PM
Roman Weller
Roman Weller - avatar
+ 3
Your program just check the input word last letter is isogram Or not. for x in word : #this iterate through all letter in word. If any word count is greater than 1 then break loop. And print false.. If all letter count is 1 only, then print true.. Hope it helps..
11th Aug 2022, 4:48 PM
Jayakrishna šŸ‡®šŸ‡³
+ 2
Why are you checking for the presence of a character in a word if the loop has already selected it from this word šŸ˜³ JaScript why are you checking a boolean variable if just printing its value is enough šŸ˜‰
11th Aug 2022, 6:14 PM
Solo
Solo - avatar
+ 1
What a tight solution! Perfect, thanks!
13th Aug 2022, 6:07 AM
Sonja
- 1
Solo yes, very good. I slept here. But in any way you have to print the result in lower letters. So at least you hve to convert the output value.
12th Aug 2022, 8:46 AM
JaScript
JaScript - avatar
- 2
# The problem is that you overwritte your count variable # In this way not word = input() iso = True for x in word: if x in word: count = word.count(x) if count > 1: iso = False break if iso: print("true") else: print("false")
11th Aug 2022, 4:49 PM
JaScript
JaScript - avatar