Let’s learn how to reverse dictionary order in Python.
Reverse a dictionary in python
To change the order it is enough just to change a and b places in the dictionary.
Just like that:
languages_I_know = {1: 'Javascript', 2: 'Kotlin', 3: 'Python'} print(languages_I_know) reversed_languages_I_know = {a: b for b, a in languages_I_know.items()} print(reversed_languages_I_know)
And that’s how the order of dictionary elements is changed.