Question 10
Back to Exercise
The program below stops with an error. Which statement correctly describes the problem?
pending = {"T1"}
pending.pop()
next_task = pending.pop()
print(next_task)
- A KeyError: the second pop() runs on an empty set; check if pending: first Correct
- B IndexError: pop from empty list
- C It prints None
- D It prints T1
Correct Answer: Option A
An empty set has nothing to pop; sets report it as KeyError.
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!