Error in syntax


#1


I have an error of syntax popping up with the lambda filtering for the garbled string.


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

File "python", line 1
garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX
^
SyntaxError: EOL while scanning string literal

Instead of this error, the X's should have been removed from the string.


garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX

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

print message


#2

missing " to mark the end of string, so python doesn't know where string ends


#3

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