Change Dictionary key


#1

How can you change dictionary keys instead of del?


#2

you can’t, you will have to remove the old key and insert a new one

we can do this in one line of we want:

dictionary[new_key] = dictionary.pop(old_key)

but it still removing and inserting


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.