- Write a script in which you construct a dictionary of your favorite things.
Some of my favorites:
Type Favorite book Jitterbug Perfume song Tom Petty - I Won't Back Down tree Cedar
- Print out your favorite book.
print(fav_dict['book'])- Print out your favorite book but use a variable in the key.
fav_thing = 'book'
print(fav_dict[fav_thing])-
Now print your favorite tree.
-
Add your favorite 'organism' to the dictionary. Make organism the new key of
fav_thing
fav_thing = 'organism'
print(fav_dict[fav_thing])-
Take a value from the command line for
fav_thingand print the value of that item from the dictionary. Maybe you want to print out all the keys to the user so that they know what to pick from. Check outinput(). Here is a link. -
Change the value of your favorite organism.
-
Get the
fav_thingfrom the command line and a new value for that key. Change the value with the user inputted value. -
Use a
forloop to print out each key and value of the dictionary.