Advertisement
viligen

cheese_showcase

Jan 26th, 2022
817
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def sorting_cheeses(**kwargs):
  2.     sorted_kwargs = sorted(kwargs.items(), key=lambda kvpt: (-len(kvpt[1]), kvpt[0]))
  3.     result = ''
  4.     for name, quantity in sorted_kwargs:
  5.         result += name + '\n' + '\n'.join([str(n) for n in sorted(quantity, reverse=True)]) + '\n'
  6.     return result
  7.  
  8. print(sorting_cheeses(Parmesan=[102, 120, 135], Camembert=[100, 100, 105, 500, 430], Mozzarella=[50, 125],))
  9.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement