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:
You can do a function like this:
def getLastItem(dictionary):
last_keyval = dictionary.popitem()
dictionary.update({last_keyval[0]:last_keyval[1]})
return {last_keyval[0]:last_keyval[1]}
This not change the original dictionary! This happen because the popitem() function returns a tuple and we can utilize this for us favor!!