QuestionQ92

VerifiedControl Flow – Conditional Blocks and Loops

How many stars does the following snippet print to the monitor?

Question Image

Explanation

The nested list comprehension produces sublists of lengths 0, 1, and 2. The condition len(d) < 2 is true for the first two sublists only, so print('*') executes twice.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!