Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
first_key = list(car.keys())[0]
orfirst_key = next(iter(car.keys()))
And no one wrote about the fact that Python < 3.6 does not guarantee the order of keys in a dictionary (hash table), like many other languages:
https://stackoverflow.com/questions/5629023/key-or...
If important so that the first key is the one that was specified first when defining the dictionary, you can use OrderedDict.
In Python >= 3.6 this problem is no longer there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question