I am having difficulty figuring out what the syntax would be for the last key in a Python dictionary. I know that for a Python list, one may say this to denote the last:

list[-1]

I also know that one can get a list of the keys of a dictionary as follows:

dict.keys()

However, when I attempt to use the logical following code, it doesn't work:

dict.keys(-1)

It says that keys can't take any arguments and 1 is given. If keys can't take arguments, then how can I denote that I want the last key in the list?

I am operating under the assumption that Python dictionaries are ordered in the order in which items are added to the dictionary with most recent item last. For this reason, I would like to access the last key in the dictionary.

I am now told that the dictionary keys are not in order based on when they were added. How then would I be able to choose the most recently added key?

Edit
Report