Accessing dictionary value by index in python [duplicate]

In Python versions before 3.7 dictionaries were inherently unordered, so what you’re asking to do doesn’t really make sense.

If you really, really know what you’re doing, use

value_at_index = list(dic.values())[index]

Bear in mind that prior to Python 3.7 adding or removing an element can potentially change the index of every other element.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)