Sorting a list based on the occurrence of a character
You're just missing the lambda for the sorting key so you have a way to reference the list item that needs occurrences of a counted
sorted(l, key = lambda x: x.count('a'))
sorted(l, key=lambda r: r.count('a'))