Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def first_dictionary():
- """
- Playing with dictionaries in part 1
- """
- about_me = { "height" : 12 ,
- "color" : "vanta",
- "author" : "james"
- }
- ask_height = input("What is my height. Type height " )
- ask_color = input("What is my favorite color. Type color " )
- ask_author = input("What is my favorite author. Type author " )
- if ask_height in about_me:
- a = about_me[ask_height]
- print("you know it's", a)
- b = about_me[ask_color]
- print("you know it's", b)
- c = about_me[ask_author]
- print("you know it's",c)
- else:
- print("not an option")
- first_dictionary()
- #create a dictionary mapping your favorite musicians to a list of your favorite songs by them
- def second_dictionary():
- """
- create a dictionary mapping your favorite musicians to a list of your favorite songs by them
- """
- bettys_songs = ["germ",1,2,3]
- jimmys_songs = ["bacteria",4,5,6]
- kims_songs = ["genome", 7,8.1,"nine"]
- musicians = {"betty": bettys_songs,
- "jimmys": jimmys_songs,
- "kims": kims_songs
- }
- print("Here is my 1st favorite musician and their songs:: ", "betty", musicians["betty"])
- print("Here is my 2nd favorite musician and their songs:: ", "jimmys", musicians["jimmys"])
- print("Here is my 3rd favorite musician and their songs:: ", "kims", musicians["kims"])
- second_dictionary()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement