Solution Review: Extracting Toppers From a Student Record
This lesson explains the solution for the "extracting toppers" exercise.
We'll cover the following...
Solution
Press + to interact
def get_top(grades):return [x['name'] for x in grades if x['percent'] >= 80]grades = [{"name": "Mary","percent": 90},{"name": "Don","percent": 55},{"name": "Bob","percent": 70},{"name": "Jim","percent": 85},{"name": "Meg","percent": 80},{"name": "Jil","percent": 75}]print(get_top(grades))
Explanation
To solve this problem, we used the list comprehension syntax.
First of ...