+ 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')
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.
+ 1
I think you must use int in the place of str
+ 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.
+ 1
Thanks for your helpš
0
What exactly is the task? And are you getting an error?
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.
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
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")
- 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
- 1
Im getting TypeError
- 1
Can you help?
- 1
Your 3rd line is gagaš¦§š¦§š¦§
Look twice.. you are not far away