Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Given names = ["Asha", "Ravi", "Meera"] and marks = [72, 85, 64], use zip and a comprehension to make (1) a dictionary of name and mark, and (2) the list of the names of the students with more than 70.
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. zip(names, marks) gives pairs (name, mark), which a comprehension can unpack.
Check. The pairs are (Asha, 72), (Ravi, 85) and (Meera, 64). The marks above 70 are 72 and 85.
Answer: {'Asha': 72, 'Ravi': 85, 'Meera': 64} and ['Asha', 'Ravi'].
Log in to join the discussion.
Loading…