13/18 What am I doing wrong?


#1

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


#2

try

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)


#3

thanks, it solved my problem!


#4

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)


#5

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


#6

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

Like using the list slicing technique within the defined lambda function


#7

Previous post explains how to do this