#13.Lambda Syntax - two different outcomes depending on list targeting


13.Lambda Syntax

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

I have doubts about why the following happens:

# option 1: it gets an error message, but the output 'Python' is on console

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

# option 2: the system passes the syntax with the output ['Python'] on console

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


Have a look the difference

 languages = ["HTML", "JavaScript", "Python", "Ruby"]
print languages[2]
print languages[2:3:1]


And here you see the difference in the Result

languages = ["HTML", "JavaScript", "Python", "Ruby"]
print type(languages[2])
print type(languages[2:3:1])


Hello Sir Leonhard Wettengmx !

and thank You for your time:

I probably didn't express myself correctly - the difference You are kindly underlying was already obvious - the outputs give a different type;
but my doubt was about the fact that the requested exercise was:

"Fill in the first part of the filter function with a lambda. The lambda should ensure that only "Python" is returned by the filter."

…and that's not as being requested to have ["Python"] on console, am I correct ?

It seems the exercise requested one thing, but the system performed another.

That's all.
Kind regards