Python Forum

Full Version: Python Dictionary Comprehension
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If you want to learn more about Python dictionary comprehension, This tutorial is for you.
Quote:Dictionary is an unordered, changeable and indexed collection of items.

This is True for Python <= 3.5.

Since Python 3.6 it's an implementation detail, that the insertion order is preserved.
Since Python 3.7 it's a language feature.

To make a list unique and keep the insertion order:
my_list = [1,1,1,3,-5,4,1]
unique_keys = list(dict.fromkeys(my_list))
Is it just me or there is really influx of links to substandard tutorials?
(Sep-21-2020, 11:25 AM)perfringo Wrote: [ -> ]Is it just me or there is really influx of links to substandard tutorials?
It's not just you.