Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
The list is marks = [45, 78, 90, 62, 38, 85, 71]. Write a loop that counts how many marks are above 70, and one that builds a list of those marks.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Two patterns: a counter with an if, and an empty list with append inside an if.
Check. The marks above 70 are 78, 90, 85 and 71. The number 70 itself would not count, because the test is > and not >=. So count is 4 and high is [78, 90, 85, 71].
Answer: 4, and [78, 90, 85, 71].
Log in to join the discussion.
Loading…