Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python add new key to dictionary

# Basic syntax:
dictionary['new_key'] = 'new_value'

# Example usage:
d = {'a': 1, 'b': 5} # Define dictionary
d['c'] = 37 # Add a new key to the dictionary
print(d)
--> {'a': 1, 'b': 5, 'c': 37}
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #python #add #key #dictionary
ADD COMMENT
Topic
Name
6+5 =