Last active
March 25, 2019 19:21
-
-
Save chicagowebmanagement/ec95b2b415be91de9b93207091cdc077 to your computer and use it in GitHub Desktop.
Gets info: stores as dictionary, outputs on single line for each k:v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Three Exercises from GoSelfTaught for Dictionaries. | |
Combining all three exercises into one file. | |
First is a simple dictionary | |
Second is a user populated dictionary | |
Third is bands to songs | |
""" | |
whoami={"height":"5\'9","fave color":"yellow","author":"stone"} | |
print(whoami) | |
print(type(whoami)) | |
print(["age"]) | |
inventory={} | |
question1 = input("Tell us your favorite color? ") | |
question2 = input("Tell us your favorite food? ") | |
question3 = input("What year were you born? ") | |
question4 = input("Who is your favorite actor/actress? ") | |
inventory={"Color":question1,"Food":question2,"Year Born":question3,"Actor/Actress":question4} | |
for key,val in inventory.items(): | |
print("{} = {}".format(key, val)) | |
print(type(inventory)) | |
songlist=dict() | |
songlist={"U2":"Bad","ELO":"Some other song","ELP":"Fanfare","Oingo Boingo":"Another crazy song"} | |
print(songlist) | |
for key,val in songlist.items(): | |
print("{} = {}".format(key,val)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment