From Python 3.7, it seems that ** dictionary order is maintained **. fromkeys() A dictionary can be generated as follows.
Input print (dict.fromkeys (["key 1 "," key 2 "," key 3 "]," value "))
Output {"Key 1 ":" Value "," Key 2 ":" Value "," Key 3 ":" Value "}
If the second argument is not specified, the value will be None. print(dict.fromkeys(l)) {3: None, 2: None, 1: None, 5: None, 4: None}```
##list() If you pass a dictionary as an argument, a list will be created from the key.
Key does not overlap ##Main subject input
l = [3, 3, 2, 1, 5, 1, 4, 2, 3]
print(dict.fromkeys(l))
print(list(dict.fromkeys(l)))
output
{3: None, 2: None, 1: None, 5: None, 4: None}`
[3, 2, 1, 5, 4]