diff --git a/python/dictionaries b/python/dictionaries.py similarity index 52% rename from python/dictionaries rename to python/dictionaries.py index a1bbe6c..10a91c4 100644 --- a/python/dictionaries +++ b/python/dictionaries.py @@ -1,10 +1,16 @@ # DICTIONARIES +# Create a new dictionary with 3 key-value pairs prices = {'shrimp':8.52, 'chicken':4.35, 'beef':6.28} print(prices.items()) + +# to get one item from our prices dictionary, use its key 'chicken' as the index print('chicken: ', prices['chicken']) # UPDATE AND ADD TO A DICTIONARY +# if beef already exists, this will update the price. +# if not, it will add beef to the dictionary prices['beef'] = 2.99 prices['pork'] = 7.55 + print(prices.keys()) print(prices.values())