Hello guys please why is my code not running. Trying to solve the Deja Vu code coach challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Hello guys please why is my code not running. Trying to solve the Deja Vu code coach challenge

letters = input() count = {} for s in letters : if s in count: count[s] += 1 else: count[s] = 1 for key in count: if count[key] > 1: break print("Deja Vu")

13th Aug 2020, 2:32 PM
Eleojo Emmanuel Adegbe
Eleojo Emmanuel Adegbe - avatar
4 Answers
+ 1
Eleojo Emmanuel Adegbe, where did you check for the other case "Unique". Also you should provide one output, but you give for string "asd" three times "Deja Vu". I recommend to create a variable for example called isRepeating set initially to False. And in the last loop if count[key] > 1 you can set it to True and break the loop. And finally check if isRepeating is True print "Deja Vu" else "Unique" 🐱
13th Aug 2020, 2:56 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
For 2 reasons. First, you are not printing "Unique" if no letter is repeated. Second, your structure of the second for loop is messed up. You are breaking out of the loop if count[key] > 1, else you are printing "Deja vu", which is quite wrong. Try it in the code playground with your custom input and you will see the problem.
13th Aug 2020, 2:53 PM
XXX
XXX - avatar
+ 1
You have not understood question correctly.. Read again.. Where is unique printing in code if input contains unique letters... And you need to print just ones 'either Deja Vu or Unigue... But your code printing more times....
13th Aug 2020, 2:54 PM
Jayakrishna 🇮🇳
+ 1
Thanks Alot TheWhiteCat.. it works
13th Aug 2020, 11:03 PM
Eleojo Emmanuel Adegbe
Eleojo Emmanuel Adegbe - avatar