1

In Python 3.5x executed the below code

for key in {'six':-99, 'one':1, '1.5': 1.5, 'two':2, 'five':5}:
    print(key)

I was expecting the output in the below order

  • six, one, 1.5, two, five

and got the below output

  • 1.5, six, five, two, one

Why this weird behaviour, that too without requesting to change the order, also why this random order ?

you can try at the below link

Run Code

luckyluke
  • 642
  • 2
  • 7
  • 22
  • Possible duplicate of [Why is the order in dictionaries and sets arbitrary?](https://stackoverflow.com/questions/15479928/why-is-the-order-in-dictionaries-and-sets-arbitrary) – awesoon Jul 20 '17 at 05:12

0 Answers0