In <598c6d74$0$1588$c3e8da3$54964...@news.astraweb.com> Steve D'Aprano 
<steve+pyt...@pearwood.info> writes:

> What would you expect this syntax to return?

> [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5]

[1, 2, 3]

> For comparison, what would you expect this to return? (Without actually
> trying it, thank you.)

> [x + 1 for x in (0, 1, 2, 999, 3, 4) if x < 5]

[1, 2, 3, 4, 5]

> How about these?

> [x + y for x in (0, 1, 2, 999, 3, 4) while x < 5 for y in (100, 200)]

[100, 101, 102, 200, 201, 202]

> [x + y for x in (0, 1, 2, 999, 3, 4) if x < 5 for y in (100, 200)]

[100, 101, 102, 103, 104, 200, 201, 202, 203, 204]

-- 
John Gordon                   A is for Amy, who fell down the stairs
gor...@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to