tegge-classroom / STAT2984-2018

STAT 2984: Statistical Programming I - Spring 2018
1 stars 13 forks source link

append something to a dictionary #10

Open bdonovan7 opened 6 years ago

bdonovan7 commented 6 years ago

How do you add something to a dictionary that is already created?

tfinch21 commented 6 years ago

I think something like this would work.

d = {'key':'value'} print(d) {'key': 'value'} d['mynewkey'] = 'mynewvalue' print(d) {'mynewkey': 'mynewvalue', 'key': 'value'}