Question 6
Back to Exercise
Someone did score 91, but the program says nobody did. Which statement correctly identifies the bug?
marks = {"Asha": 91, "Ravi": 78}
if 91 in marks:
print("Someone scored 91")
else:
print("Nobody scored 91")
- A in on a dict checks the keys (names); use 91 in marks.values() Correct
- B in only works on lists
- C 91 must be a string
- D The dict must be sorted first
Correct Answer: Option A
Membership, iteration and len() all work on keys by default.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!