File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -154,18 +154,18 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence
154
154
(such as a string, tuple, or list) or other iterable object:
155
155
156
156
.. productionlist :: python-grammar
157
- for_stmt: "for" `target_list ` "in" `expression_list ` ":" `suite `
157
+ for_stmt: "for" `target_list ` "in" `star_expressions ` ":" `suite `
158
158
: ["else" ":" `suite `]
159
159
160
- The `` expression_list `` is evaluated once; it should yield an :term: `iterable ` object.
160
+ The expression following `` in `` is evaluated once; it should yield an :term: `iterable ` object.
161
161
An :term: `iterator ` is created for that iterable. The first item provided by the iterator
162
162
is then assigned to the target list using the standard rules for assignments
163
163
(see :ref: `assignment `), and the suite is executed. This repeats for each item provided
164
164
by the iterator. When the iterator is exhausted, the suite in the :keyword: `!else ` clause,
165
165
if present, is executed, and the loop terminates.
166
166
167
- Note that as of Python 3.11, unpacking with starred expressions (e.g., ``*x ``) is supported
168
- in the iterable expression list .
167
+ As of Python 3.11, unpacking with starred expressions (e.g., ``*x ``) is supported
168
+ in the iterable expression. This follows the same rules as :token: ` star_expressions ` in the grammar .
169
169
170
170
.. index ::
171
171
pair: statement; break
You can’t perform that action at this time.
0 commit comments