Question 6
Back to Exercise
A student with grade C is told they have a distinction. Which statement correctly identifies the bug?
grade = "C"
if grade == "A" or "B":
print("Distinction")
else:
print("Keep working")
- A Strings cannot be compared with ==
- B else must be elif
- C grade should be lowercase
- D The condition is (grade == "A") or "B", and the non-empty string "B" is always truthy; write grade in ("A", "B") Correct
Correct Answer: Option D
or does not distribute over ==. Each comparison must be written in full, or use in.
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!