+ 1

Help! Why is this wrong? Isogram question in code coach

word = str(input()) for i in word: if i in word.count(i) == 1: print ('True') else: print('False')

12th Jul 2022, 7:55 AM
siti adilah sa
siti adilah sa - avatar
12 Answers
+ 1
I believe it's due to the line where you are using the count method. Try to rethink your logic with that. I recommend doing pseudocode before jumping straight into coding.
12th Jul 2022, 8:51 AM
Justice
Justice - avatar
+ 1
I think you must use int in the place of str
13th Jul 2022, 11:21 PM
Kelly ATEMENOU
Kelly ATEMENOU - avatar
+ 1
I have tried using another method. I removed duplicate characters in the string by using set() functions. Then, i compared the length of the string before and after removing the duplicate. If the length is the same, then it is an isogram. Example: #Before removing duplicate ==after removing duplicate 'come' == 'come' is an isogram # 4 char == 4 char 'hello' == 'helo' is not an isogram # 5 char != 4 char if i am not mistaken, set function also rearrange the char in alphabetical order. so the output might not be exactly as I have written in the example.
14th Jul 2022, 8:34 AM
siti adilah sa
siti adilah sa - avatar
+ 1
Thanks for your helpšŸ˜
14th Jul 2022, 8:34 AM
siti adilah sa
siti adilah sa - avatar
0
What exactly is the task? And are you getting an error?
12th Jul 2022, 8:25 AM
Justice
Justice - avatar
0
You want to check if "i" - letter is in your "word" - string. i in word would be correct as word is string which is iterable data type. When you do word.count(i) you get int type, which is not iterable. You just combined different solutions and ended up with an error, so just stick to 1 and you will be fine.
12th Jul 2022, 10:36 AM
Herr Rozwel
Herr Rozwel - avatar
0
...set a flag to true for I in word: if word.count(i)==1: do nothing else: set flag to false and break ... output flag
13th Jul 2022, 1:41 PM
Oma Falk
Oma Falk - avatar
0
Isogram_detect = input("") A_count = Isogram_detect.count("a") B_count = Isogram_detect.count("b") C_count = Isogram_detect.count("c") if A_count or B_count or C_count > 1: print("false") else: print("true")
17th Aug 2024, 4:32 PM
SatyaPrakash Mishra
SatyaPrakash Mishra - avatar
- 1
An isogram is a word that has no repeating letters, whether they are consecutive or non-consecutive. Your job is to find a way to detect if a word is an isogram. Task: Write a program that takes in a string as input, detects if the string is an isogram and outputs true or false based on the result. Input Format: A string containing one word. Output Format: A string: true or false. Sample Input: turbulence Sample Output: false
12th Jul 2022, 8:33 AM
siti adilah sa
siti adilah sa - avatar
- 1
Im getting TypeError
12th Jul 2022, 8:35 AM
siti adilah sa
siti adilah sa - avatar
- 1
Can you help?
13th Jul 2022, 3:13 AM
the we are
the we are - avatar
- 1
Your 3rd line is gagašŸ¦§šŸ¦§šŸ¦§ Look twice.. you are not far away
13th Jul 2022, 1:46 PM
Oma Falk
Oma Falk - avatar