13/18 Lambda Syntax



Oops, try again. It looks like your filter() didn't print ['Python'] to the console.

I found that some users write x:x=="Python" , but another person said he just let x="Python".

So somebody help me! thank u~

languages = ["HTML", "JavaScript", "Python", "Ruby"]
print filter(lambda x:"Python" in languages, languages)


The function provides the internals for iterating the object (languages list). That is why,

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

prints ['Python'].

If we set it to filter the opposite,

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

we get, ['HTML', 'JavaScript', 'Ruby'].


A post was split to a new topic: Can anyone explain