From 9d41e542dc39e4838c0adb4668a23f22ebbc3a42 Mon Sep 17 00:00:00 2001 From: Samuel Huang Date: Wed, 12 Aug 2026 17:47:04 -0700 Subject: [PATCH] Fix comprehension semantics for tuple example --- ultimatepython/fundamentals/comprehension.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ultimatepython/fundamentals/comprehension.py b/ultimatepython/fundamentals/comprehension.py index 58643fd..b8e16f6 100644 --- a/ultimatepython/fundamentals/comprehension.py +++ b/ultimatepython/fundamentals/comprehension.py @@ -22,7 +22,8 @@ def main() -> None: # with a list of 3-5 letter words words = ["cat", "mice", "horse", "bat"] - # Tuple comprehension can find the length for each word + # Python has no tuple comprehension syntax; this is a generator + # expression consumed by tuple() to create the final tuple tuple_comp = tuple(len(word) for word in words) assert tuple_comp == (3, 4, 5, 3)