Exam-style question
Try this first
Which expression tests whether the list xs is empty?.
- A.xs == []
- B.xs == [0]
- C.len(xs) == 1
- D.xs[0] == []
Model answer
What a good answer should say
- xs == []
Explanation
Why this works
The expression xs == [] is true exactly when xs contains no elements.
Common mistake
No common mistake is linked to this question yet.
