13/18 Lambda Syntax


#1



https://www.codecademy.com/courses/python-beginner-en-KAgt5/3/2?curriculum_id=4f89dab3d788890003000096

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)


#2

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'].


#3

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


#4