If name_scores is a dict with names as keys and lists of scores as values such as:
name_scores = {'Jem':[8,4,5],'Rob':[9,1,5], 'Liah':[9], 'Zambia':[3]}
Then you can can get your required output by doing the following:
for name, scores in sorted(name_scores.items(),key=lambda x: max(x[1]), reverse=True):
print(name,'-',max(scores))
How it works:
name_scores.items() produces a list of (name, scores) tuples.
lambda is used to define a function which returns the maximum score for each tuple.
Using sorted on a sequence with the key option will pass each item in the sequence to a function and sort by the value returned by the function. In this case we use sorted using the lambda function as a key.
If you are having trouble understanding the use of lambda functions it is often helpful to consider the following equivalent code without lambda functions:
def max_score(x):
return max(x[1])
name_scores = {'Jem':[8,4,5],'Rob':[9,1,5], 'Liah':[9], 'Zambia':[3]}
for name, scores in sorted(name_scores.items(), key=max_score, reverse=True):
print(name,'-',max(scores))