I get the code given down below on sololearn challenge, can somebody tell me why here the dictionary length is coming out 4? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I get the code given down below on sololearn challenge, can somebody tell me why here the dictionary length is coming out 4?

d = {'s':'o', 'l':'o', 'l':'e', 'a':'r', 'n':'!'} print(len(d)) I also tried it with some other examples but only in this its happening, in others the length is coming 5, and here also it should be 5 then what's the problem...

7th Apr 2020, 7:18 AM
Sp Maurya
Sp Maurya - avatar
2 Answers
+ 3
If key is already exist in dictionary, then the value is just replaces old value. Not allows dublicate key in dictionary... So only 4 keys with 4 values...
7th Apr 2020, 7:27 AM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 got it... I didn't noticed that earlier... 😅
7th Apr 2020, 7:33 AM
Sp Maurya
Sp Maurya - avatar