Different outputs | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
1st Aug 2017, 9:48 AM
Roshan Kumar
Roshan Kumar - avatar
3 Answers
+ 3
First of all for i in ages: in each times i is string not number But different output Idk
1st Aug 2017, 10:02 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 2
since the keys and values are randomly placed in dictionary unlike lists therefore you get random outputs.. for second case u can access the Dictionary by the key.. but u r trying to use 0,1 (thinking it as indices. right?) it is not possible in dictionary..
1st Aug 2017, 10:03 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
I don't really know semantics of Python, but I think that dictionaries are hash tables which means they are not stored in particular order, but the hash is calculated for each one of them and with the number they get, they get placed in memory.
1st Aug 2017, 10:39 AM
Jakub Stasiak
Jakub Stasiak - avatar