Skip to content

Commit 22b783a

Browse files
authored
Docs: Update SyntaxError message in REPL example for list comprehension (pythonGH-93901)
1 parent ac8a7b9 commit 22b783a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/tutorial/datastructures.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ it must be parenthesized. ::
268268
[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]
269269
>>> # the tuple must be parenthesized, otherwise an error is raised
270270
>>> [x, x**2 for x in range(6)]
271-
File "<stdin>", line 1, in <module>
271+
File "<stdin>", line 1
272272
[x, x**2 for x in range(6)]
273-
^
274-
SyntaxError: invalid syntax
273+
^^^^^^^
274+
SyntaxError: did you forget parentheses around the comprehension target?
275275
>>> # flatten a list using a listcomp with two 'for'
276276
>>> vec = [[1,2,3], [4,5,6], [7,8,9]]
277277
>>> [num for elem in vec for num in elem]

0 commit comments

Comments
 (0)