Filter and Lambda function in Python3


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/advanced-topics-in-python/exercises/lambda-expressions?action=lesson_resume

```python

Hey, i think i understand the filter and lambda function in python 2. But when i try this on my pc with python 3 i just get

<filter object at 0x00000245D429A828>

I hope someone can help me even if it is python3


garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX"

message = filter(lambda x: x != "X", garbled)
print message

#2

yes, filter() no longer produces a list as standard output in python3 (filter object is more efficient), if we want a list we can cast the filter object to list:

message = list(filter(lambda x: x != "X", garbled))

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.