I know this may be a simple question but I'm having trouble reversing my dictionary. All the solutions I've seen haven't been working for me. I have a dictionary where the keys are strings and the values are either None or type int. I want to reverse the order so the last (key, value) pair is first and vice versa.
For example:
d = {"pointA": 100, "pointB": 140, "pointC": None, "pointD: None}
I want to reverse the dictionary to:
reversed_d = {"pointD": None, "pointC": None, "pointB": 140, "pointA": 100}
I've tried sorted(d.items(), reverse=True)
and reversed(sorted(d.items()))
but I got an error of:
TypeError: '<' not supported between instances of 'int' and 'str'