Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Doc/tutorial/datastructures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,18 @@ and it's equivalent to::
Note how the order of the :keyword:`for` and :keyword:`if` statements is the
same in both these snippets.

For multiple :keyword:`!if` statements, like this::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those aren't if statements but if clauses.


>>> [x for x in range(10) if x % 2 if x % 3]
[1, 5, 7]

This example is equivalent to::

>>> [x for x in range(10) if x % 2 and x % 3]
[1, 5, 7]

Note the second :keyword:`!if` is replaced by :keyword:`!and`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note the second :keyword:`!if` is replaced by :keyword:`!and`.
Note that the second :keyword:`!if` has been replaced with :keyword:`!and`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding 'that' would be correct if we add the note and patch, but I am considering whether to do so.


If the expression is a tuple (e.g. the ``(x, y)`` in the previous example),
it must be parenthesized. ::

Expand Down
Loading