I created a function that takes a dictionary as parameter. This dictionary is expected to have lists as value pair. (i.e. {1: [1, 2, 3], 'a': [4, 'b', 5, 'c']}
)
This function has to return the key associated to the biggest list in the dictionary, or None
if the dictionary is empty. (considering the above example, it would return 'a'
)
I came up with this code:
def biggest(aDict):
return None if not aDict else [x for x in aDict if len(aDict[x]) == max(len(x) for x in aDict.values())][0]
Can I have some review on this and any ideas on how to further simplify without using external libraries?