Back
I want to change the key of an entry in a Python dictionary.
Is there a straightforward way to do this?
You can easily do it in one step, use the following code:
dictionary[new_key] = dictionary[old_key]del dictionary[old_key]
dictionary[new_key] = dictionary[old_key]
del dictionary[old_key]
31k questions
32.8k answers
501 comments
693 users