Rémi Lapeyre <remi.lape...@henki.fr> added the comment: Hi Su Zhu, this is expected, as per the documentation, filter returns an iterable and not a list. The first `list(a)` consumes the iterable so it is empty when doing the second `list(a)`. You can see the same behavior when creating an iterable manually:
>>> a = iter([1, 2, 3]) >>> list(a) [1, 2, 3] >>> list(a) [] If you need to keep the result in a list, you can do: >>> a = list(filter(lambda x:x, [1,2,3])) ---------- nosy: +remi.lapeyre _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37739> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com