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]
30.9k questions
32.9k answers
500 comments
665 users