garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX"message = filter(lambda i: ns for i in range() if i == X, garbled)Please help. This is my error message:

File "python", line 3SyntaxError: Generator expression should be parenthesized if not single argumentthis is what the supervisor/teacher/prompt stated to try to describe this^

Oops, try again. Your syntax doesn't look fairly right. Take a look at the note if you require help!I need HELP!!! and THE hint DOESN’T aid ME!!!

Answer 52cb27a480ff33706600d7df

4 votes


when you’re using filter() the very first part that the expression must be something the discussion being passed to it can either accomplish as true or no (x is a placeholder for the argument here, eventually it will be the item in garbled)

It looks prefer you’re coincidentally combining perform comprehension and lambda declaration here. Her lambda expression can be much easier than that. This is a very an easy list and lambda expression.

You are watching: Generator expression must be parenthesized if not sole argument

sampleList = <“a”, “b”, “a”, “c”, “a”>filteredList = filter(lambda item: item == “a”, sampleList)

Now filteredList = <“a”, “a”, “a”> due to the fact that the lambda expression just took items in the list that were true because that item == “a”.

In short, every you require to offer filter() is some kind of true/false test and a list of items to run with the test.


Submitted through Odradek
almost 8 years


G. A. Neal end 7 years

Thanks! i’ve been having actually trouble wrapping my mind approximately the lambda expression. ☺

Alex Rodriguez end 7 years

Best explaination top top the filter hatchet so much - Thanks!

Answer 533648a17c82ca9bc5003a21

2 votes


Here is the exactly solution:

garbled = “IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX”message = filter(lambda x: x!= “X”, garbled)print message


Submitted by Alina K.

See more: Rising Of The Shield Hero Episode 14 Review: Everlasting Memory

over 7 years


Noa Shoe end 7 years

i though != just ment does no equal. Why/ exactly how does that eliminate the “X”‘s?

matthew_marcus end 7 years

In this case, you’re basically filtering the end what does not equal “X” and putting that in the article variable.





Individual Plans

Enterprise Plans



Course Catalog