Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15671

Why I can not convert filter object to list [duplicate]

$
0
0

I am having trouble in converting a filter object to a list, when it can be converted to set

list_nums_2 = [2, 4, 5, 9, 8, 7, 6, 3, 1, 0]evens = filter(lambda a: a % 2 == 0, list_nums_2)print(set(evens))  # Out: {0, 2, 4, 6, 8}print(list(evens)) # Out: []

I know it's not because it's converted to set already as from below it is clear that set can be converted to list

set_1 = {2, 3, 4, 5, 6}print(list(set_1))  # Out: [2, 3, 4, 5, 6]

Viewing all articles
Browse latest Browse all 15671

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>