Lamba Syntax Problem, nothing is working


#1

On the Lambda syntax lesson, it tells you to fill in the first part of the function (the underlines) with lambda and the second part with languages. I have tried a dozen variations, and nothing seems to work. I get syntax errors, filter errors, number of argument errors. I cant seem to get it right. Here's a number of the lines I've tried.
print filter(lambda, languages) (invalid syntax error pointing at the comma)
print filter(lambda: languages) (filter expected 2 arguments, got 1)
print filter(lambda: "Python", languages) (type error, lambda takes no arguments, 1 given)
print filter(lambda, "Python", languages) (invalid syntax error pointing at the comma)
print filter(lambda: Python, languages) (type error, lambda takes no arguments, 1 given)
print filter(lambda, Python, languages) (invalid syntax error pointing at the comma)
what am I missing here?


#2

is the closest.

print filter(lambda x: x == "Python", languages)

We would appear to need an internal variable.


#3

Thanks mtf, I tried what you showed here, but it didn't work, it gave an error message about the statement cannot include an assignment statement. I looked again, and tried a double equals sign (==) like in the example, and it worked!


#4

My typo. Sorry. Still deserves to be the solution,.. Just saying.


#5

I did it like this and it worked:

print filter(lambda x: x == languages[2], languages)


#6

Kind of defeats the filter if we specify which element to target. We should be looking at content without caring where it is located.