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


#1

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]


#2

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


#3

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.


#4

garbled = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"

reverse = garbled[::-1]

tam = len(reverse)

message = reverse[0:tam:2]

print message


#5

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


#6

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.


#7

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


#8

garbled = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"
message=garbled[::-1]
print message.replace('X','')


#9

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