python add to dictionary value code example
Example 1: how to add an item to a dictionary in python
a_dictonary = {}
a_dictonary.update({"Key": "Value"})
Example 2: add value to dictionary python
dict[key] = value
Example 3: python append to dictionary
dict = {1 : 'one', 2 : 'two'}
# Print out the dict
print(dict)
# Add something to it
dict[3] = 'three'
# Print it out to see it has changed
print(dict)
Example 4: python dictoinary add value
student_scores = {'Simon': 45 }
print(student_scores)
# {'Simon': 45}
student_scores['Sara'] = 63
print(student_scores)
# {'Simon': 45, 'Sara': 63}