Skip to content

Commit de09ddf

Browse files
authored
Fix comprehension semantics for tuple example (#211)
1 parent ce3e119 commit de09ddf

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎ultimatepython/fundamentals/comprehension.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def main() -> None:
2222
# with a list of 3-5 letter words
2323
words = ["cat", "mice", "horse", "bat"]
2424

25-
# Tuple comprehension can find the length for each word
25+
# Python has no tuple comprehension syntax; this is a generator
26+
# expression consumed by tuple() to create the final tuple
2627
tuple_comp = tuple(len(word) for word in words)
2728
assert tuple_comp == (3, 4, 5, 3)
2829

0 commit comments

Comments
 (0)