My code works correctly but why won’t the hidden message print to the console? I can print the contents of garbled until I reverse it and remove the x’s, then it won’t print the hidden message.
How can you tell that it’s correct if you’re not able to confirm the result?
It’s printed just fine from what I can tell. There just isn’t very much to print, you’re creating an empty string!
When I submit the lesson, codecademy indicates that it is the correct answer and prompts me to the next lesson. Why would it print an empty string? It should print “I am the secret message!” The question is, since it prints the variable garbled, why won’t it print the variable garbled or the variable message once it has been ungarbled? I ran it in Python’s idle and it doesn’t print there either. It only prints the original content of garbled.
Because that’s the value that your variable refers to.
codecademy indicates that it is the correct answer
Then it’s either wrong or you have different ideas of what’s correct. If you haven’t seen the result yourself then you’ve got no way of telling that your code does what you think it does, which is all that matters.
<do not remove the three backticks above>Continuing the discussion from [17. List Slicing-Printing the message](https://discuss.codecademy.com/t/17-list-slicing-printing-the-message/34040):
Mr. Hyrundo, if you use:
message = garbled[2:len(garbled): -2]
your new message will star in the first blank space not in the letter “I” as you expected.
I know this is a traditional way and a bit lengthy but the code works.
garbled = “!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI”
backwards = garbled[::-1]
print backwards
new =
for x in backwards:
if x!= ‘X’:
new.append(x)
new = “”.join(new)
print new
It prints out “I am the secret message”, but I get an error when I save/submit saying “Oops, try again. Your message doesn’t look quite right; instead of “I am the secret message!”, it should be “!egassem terces eht ma I””
it displays the correct message but gives this error:
Oops, try again. Your message doesn’t look quite right; instead of “I am the secret message!”, it should be "!gse ecsetm "
but if you write the way @arbol saying it works with no error.