+ 3

I don't know why this code doen't solve the 2nd test case.Can anyone find the bug,please

deja Vu solution bug https://code.sololearn.com/cLaqw7KRzaHF/?ref=app

20th Oct 2020, 3:58 PM
Arrahman Abtahi
3 Respostas
+ 1
text = input() d = dict.fromkeys(text, 0) print(d) for c in text: d[c] += 1 print(d) if any(i>1 for i in d.values()): print("Deja Vu") else: print("Unique") In your solution a=d[c] is storing value of the last character which can have a value greater than 1 or not ,if it doesn't have value greater than 1 then it will output unique even if other characters before it are repeated
20th Oct 2020, 4:07 PM
Abhay
Abhay - avatar
+ 3
Abhay thanks for helping I understood what was the bug in my solution
20th Oct 2020, 4:13 PM
Arrahman Abtahi
+ 2
Arrahman Abtahi your code will only work if the last character of the string is repeated because you are checking that only.
20th Oct 2020, 4:08 PM
Arsenic
Arsenic - avatar