Tom Clark
Aug 8, 2024

Two thoughts:

1. Nested list comprehensions are incomprehensible. The reader has to pause and spend 30 seconds to figure out what’s happening; then maybe get it wrong. Please, from a senior engineer who has to review code every day: Just. don’t.

2. There’s a mistake in the dictionary comprehension; you mean
print({ i: len(i) for i in apple_names})

Tom Clark
Tom Clark

Written by Tom Clark

Fluid Dynamicist at the core, lover of chaos theory. Experienced scientist, developer and team lead working in wind energy — from startups to heavy industry.

Responses (3)