Change Dictionary key


How can you change dictionary keys instead of del?


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


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