- 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])
-
Use a
for
loop to print out each key and value of the dictionary. -
Take a value from the command line for
fav_thing
and print the value of that item from the dictionary. -
Print out all the keys to the user so that they know what to pick from. Check out
input()
. Here is a link about input -
Change the value of your favorite organism.
-
Get the
fav_thing
from the command line and a new value for that key. Change the value with the user inputted value. And print out a confirmation.