SyntaxFix
Write A Post
Hire A Developer
Questions
sorted(dict.keys())[-1]
Otherwise, the keys is just an unordered list, and the "last one" is meaningless, and even can be different on various python versions.
keys
Maybe you want to look into OrderedDict.