How to fix KeyError: 'key_name' in Python | DevErrors