+ 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")
4 Respuestas
+ 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" 🐱
+ 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.
+ 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....
+ 1
Thanks Alot TheWhiteCat.. it works