Code won't work, why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
15th Feb 2018, 4:28 PM
voja
voja - avatar
6 Answers
+ 5
Dictionaries don't maintain the order of their elements. Try collections.OrderedDict instead. EDIT: thought I might mention that dictionaries are ordered from Python 3.6 onward. Sololearn still uses Python 3.5, though, so... yeah.
15th Feb 2018, 4:33 PM
LunarCoffee
LunarCoffee - avatar
+ 5
All you need is print(dic[k]) print(dic2[e])
15th Feb 2018, 6:51 PM
Louis
Louis - avatar
+ 4
No Problem, thats the joys of programming.
15th Feb 2018, 7:11 PM
Louis
Louis - avatar
+ 3
@LunarCoffee Thanks a lot 😃 . I didn't know that.
15th Feb 2018, 4:45 PM
voja
voja - avatar
+ 3
@Louis MIND-BLOWING I spent hours trying to find a solution and you tell me that I only need these two simple lines 😱 I guess that's why you are platinum... am just bronze 😔 Anyway, HUGE THANK YOU !!!
15th Feb 2018, 7:09 PM
voja
voja - avatar
+ 2
I've tried almost everything and it still won't work:( If someone knows how to make this code work (i mean, to get the output I want) with collections or without, I would be happy
15th Feb 2018, 6:07 PM
voja
voja - avatar