Leidingfei
10/2/2019 - 12:58 PM

hectorng_dict.py

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  " )

    ## this if statement only looks at the keys of about_me
    ## I think what you want is -->
    ## if ask_height in about_me.values():
    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")





## only put two blank lines between functions
#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"])


## only put two blank lines between the end of a function and main code
## define all your functions first, and then call them at the bottom
first_dictionary()
## to pause between these - you'll want to use sleep() from the time module
## google time.sleep() to learn more!
second_dictionary()