Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python change a key in a dictionary

# Basic syntax:
# Approach 1:
dictionary[new_key] = dictionary[old_key]
del dictionary[old_key]

# Approach 2:
dictionary[new_key] = dictionary.pop(old_key)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #change #key #dictionary
ADD COMMENT
Topic
Name
1+4 =