# Practice Dictionary Problem def look( d ): # d is a dictionary we pass in biggest = max( d.values() ) print("Dictionary keys: ", d.keys()) print("Dictionary values: ", d.values() ) # We know that biggest is the largest value. # Now we want to see which key has the largest value (biggest) # How do we search through the keys? for k in d.keys(): # for k in d: (also loops through keys) v = d.get( k ) # or d[k] if ( v == biggest ): result = k #or just return k # Return the key mapped to the largest value return result # return biggest # returns the largest value # Remember dictionaries are {k:v,k:v} # Remember that there is a dictionary module on the website: # d.values() -> gives you a set of values (where d is the dictionary) # d.keys() -> gives you a set of keys (where d is the dictionary) if __name__ == '__main__': d1 = { 'a': 1, 'b': 5, 'c': 4, 'd': 6, 'e':1 } result = look( d1 ) print( result )