I have the following string and I wanna decode by filtering the X's
garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX"
And I would like to filter. I tried the following code
message = filter(lambda x: garbled.remove(x) if x == "X", garbled)
I did not make this way work. I have found this other solution:
message = filter(lambda x: x != "X", garbled)
But I still wonder why did not work the first one. Can I fix it?
(I am new in python btw) thanks!
'X's?removemethod, because strings are immutable. Your first attempt didn't work because it's trying to call a method that doesn't exist.decoded = garbled.replace('X', '')?"X"you want to keep?