We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
if
1 parent 0dbbf61 commit 0c74847Copy full SHA for 0c74847
Doc/tutorial/datastructures.rst
@@ -245,6 +245,18 @@ and it's equivalent to::
245
Note how the order of the :keyword:`for` and :keyword:`if` statements is the
246
same in both these snippets.
247
248
+For multiple :keyword:`!if` statements, like this::
249
+
250
+ >>> [x for x in range(10) if x % 2 if x % 3]
251
+ [1, 5, 7]
252
253
+This example is equivalent to::
254
255
+ >>> [x for x in range(10) if x % 2 and x % 3]
256
257
258
+Note the second :keyword:`!if` is replaced by :keyword:`!and`.
259
260
If the expression is a tuple (e.g. the ``(x, y)`` in the previous example),
261
it must be parenthesized. ::
262
0 commit comments