Not picking repeated m in sammich | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Not picking repeated m in sammich

word = str(input()) letters = word.split() for i in letters: count = letters.count(i) if count > 1: print('Deja Vu') else: print('Unique')

5th Apr 2020, 5:51 PM
Kim 🐘
Kim 🐘 - avatar
5 Answers
+ 1
word = str(input()) for i in word: count = word.count(i) if count > 1: print('Deja Vu') else: print('Unique')
5th Apr 2020, 6:43 PM
Oma Falk
Oma Falk - avatar
+ 1
"sammich" . split() evals to ["sammich"]
5th Apr 2020, 7:41 PM
Oma Falk
Oma Falk - avatar
0
Is not the same?
5th Apr 2020, 6:51 PM
Kim 🐘
Kim 🐘 - avatar
0
even with Oma Falk's correction...your output is:- Unique Unique Deja Vu Deja Vu Unique Unique Unique Don't think that is what you're after is it? You need to define a function that returns True or False and use that in a print function .
5th Apr 2020, 8:07 PM
rodwynnejones
rodwynnejones - avatar
0
you could take the change made by Oma Falk and in if return true and in the else return false in a function called IsDuplicate(word, letter) and call the function from the for loop instead of the if many other ways and styles, happy to discuss more if interested
5th Apr 2020, 8:24 PM
SQrL
SQrL - avatar