Lists
A list comprehension builds a new list in one line: [x for x in items if condition] reads almost like the English sentence it describes - "x, for each
x in items, where condition holds." It replaces the loop-plus-append pattern
you'd otherwise write by hand.
You can drop the if entirely to transform every item instead of filtering
them ([x * 2 for x in items]), but this lesson is about keeping some items
and dropping others, so the condition is the part that matters.
Your task: given the list scores, write passing(scores), returning a
new list with only the scores that are 60 or above.
You'll practice:
- Filtering a list with a list comprehension
- Writing a condition inside the comprehension