Serhiy Storchaka <storch...@gmail.com>: > 10.08.17 17:28, Steve D'Aprano пише: >> What would you expect this syntax to return? >> >> [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5] > > I would expect it to be equivalent to the following code: > > result = [] > for x in (0, 1, 2, 999, 3, 4): > while x < 5: > result.append(x + 1)
And I would expect this: result = [] for x in (0, 1, 2, 999, 3, 4): if not x < 5: break result.append(x + 1) Marko -- https://mail.python.org/mailman/listinfo/python-list