There was an error while loading. Please reload this page.
1 parent ce3e119 commit de09ddfCopy full SHA for de09ddf
1 file changed
ultimatepython/fundamentals/comprehension.py
@@ -22,7 +22,8 @@ def main() -> None:
22
# with a list of 3-5 letter words
23
words = ["cat", "mice", "horse", "bat"]
24
25
- # Tuple comprehension can find the length for each word
+ # Python has no tuple comprehension syntax; this is a generator
26
+ # expression consumed by tuple() to create the final tuple
27
tuple_comp = tuple(len(word) for word in words)
28
assert tuple_comp == (3, 4, 5, 3)
29
0 commit comments