Lambda Expressions


#1

Hey there all you Python students (and hopefully Codecademy mods/devs),

There may be a bug in the lesson, "Lambda Expressions".

The preloaded code in the editor is:

garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX"

The code which I entered just below the preloaded code is:

print filter(lambda x: x != "X", garbled)

...which, when run, yields to the console:

I am another secret message!
None

...which should be correct, however I receive the error:

"Oops, try again. It looks like your message is "I am the secret message!" instead of "I am another secret message!""

...when indeed my result was, "I am another secret message!" as per the provided garbled string in the preloaded code. The workaround I have found is to actually produce the output, "I am the secret message!" even though the error message explicitly states that this is incorrect. I accomplished this by removing "aXXXnXoXXXXX" from before "tXhXe" and "XXXXrX" from after it in the provided garbled string.

If I have made a mistake, I would appreciate it being pointed out to me! If this is truly a bug, then it would appear that the Codecademy devs would need to fix the answer check function for this lesson.

Is anyone else seeing this?


#2

the instructions state that you should store the result of the filter action in a variable, then print the variable

You tried to take a little shortcut, sometimes that works in the lessons, sometimes (like now) it doesn't)


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.