17/18 Right Output But CA says it is an error

This code returns the right output in Code Academy output window and in my Python interpreter - but I get an error message. Any ideas?

garbled = “!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI”

message = garbled[::-1]

print message[0::2]

1 Like

message = garbled[::-2]
this save the secret message inside the string
:smile:

1 Like

So I think the issue here is that codecademy is looking at what is in the message variable to determine if you are correct, not what you are printing out to console. So if you do

message = garbled[::-2]

you should be all set.

1 Like

garbled = “!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI”

reverse = garbled[::-1]

tam = len(reverse)

message = reverse[0:tam:2]

print message

You could just do message = garbled[::-2].

You can also put it this way:

garbled=garbled[0::2]
message=garbled[::-1]

But be warned, the tutorial doesn’t accept it. Yet, it works as intended.

1 Like

Could you pls explain more about this exercise?
What is happening in each step?
Thnx

garbled = “!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI”
message=garbled[::-1]
print message.replace(‘X’,’’)

garbled = “!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI”
message = filter(lambda x: x, garbled[::-2])