13/18 What am I doing wrong?


languages = ["HTML", "JavaScript", "Python", "Ruby"]
print filter(lambda x: for l in x if l[0] == "P" return l, languages)



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

what the filter does is it filters a given list(i.e. gives you a modified list) . the filtration process which is the rule to filter the list by is given by the lambda expression(anonymous functions)


thanks, it solved my problem!


One more option:
this filter filters word with index 2 from list languages

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


don't use if, just x[0] == "P"
your way is simple and good


How can we solve the problem without writing "Python" ?

Like using the list slicing technique within the defined lambda function


Previous post explains how to do this