Deja Vu bug | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Deja Vu bug

I have made two solution to the problem the first one works fine but the other one is creating problem, it is always printing "Deja Vu" . Pls help me find the bug. https://code.sololearn.com/cjN4V5ngczDm/?ref=app

30th Mar 2022, 1:03 PM
Shaurya Agarwal
Shaurya Agarwal - avatar
5 Answers
+ 6
set does not maintain the order so list(set(listt) ) will not maintain elements order as it is in listt. *May not same as list values in order even when have same values. So may return false mostly.
30th Mar 2022, 1:11 PM
Jayakrishna 🇮🇳
+ 7
we don't need to care about the order of a set, if we compare the length of the original input and the length of a set of the original input. converting a string to a set will remove all duplicated characters. word = input() if len(word) == len(set(word)): print('Unique') else: print('Deja Vu')
30th Mar 2022, 4:30 PM
Lothar
Lothar - avatar
+ 2
Lothar thanks, that was a great use of "len()"
30th Mar 2022, 5:00 PM
Shaurya Agarwal
Shaurya Agarwal - avatar
+ 1
Jayakrishna🇮🇳 thankyou so much
30th Mar 2022, 1:15 PM
Shaurya Agarwal
Shaurya Agarwal - avatar
0
You're welcome...
30th Mar 2022, 1:16 PM
Jayakrishna 🇮🇳