0 votes
1 view
in Python by (45.2k points)

I want to change the key of an entry in a Python dictionary.

Is there a straightforward way to do this?

1 Answer

0 votes
by (16.8k points)
edited by

You can easily do it in one step, use the following code:

dictionary[new_key] = dictionary[old_key]

del dictionary[old_key]

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !