A
A
Alexander Shapoval2018-09-25 11:38:05
Python
Alexander Shapoval, 2018-09-25 11:38:05

Why does Python output dict() randomly and not in the order I declared it?

x = dict({
    'a': 1,
    'c': 3,
    'b': 2,
})

outputs {'b': 2, 'a': 1, 'c': 3}, with each run outputting a different value.
How can I make it appear the way I created it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kisaa, 2018-09-25
@kisaa

Google it, maybe?
https://www.google.com/search?q=python+sorted+dict...
Override sort function to taste.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question