Question 13
Back to Exercise
What does len(x for x in range(5)) do?
- A Returns 5
- B Returns 0
- C Raises TypeError – generators have no length Correct
- D Returns None
Correct Answer: Option C
A generator does not know how many values it will produce. Use sum(1 for …) or build a list.
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!