''' Purpose: demonstrate dict mappings ''' # get access to url support import url # where is the dog to notoriety mappings PUPPIES_CSV = 'http://www.cs.virginia.edu/~cs1112/datasets/csv/puppies.csv' # get data set dataset = url.get_dataset( PUPPIES_CSV ) # convert dataset to a form suitable for querying notoriety = { } # specifies an empty dictionary # no entries or mappings for row in dataset : # for each line in the csv name, fame = row notoriety[ name ] = fame # adds a new mapping to notoriety; the dict is now not empty print( dataset ) print( notoriety ) # ask for dog of interest reply = input( 'Enter name of dog: ' ) dog = reply.strip() dog = dog.capitalize() # look up claim to fame fame = notoriety.get( dog ) print( fame )