List slicing - Unsure why incorrect?


#1



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


Prints:
I am the secret message!
None

But gives me a message "Oops, try again. Your message doesn't look quite right; instead of "I am the secret message!", it should be "!gse ecsetm ""


garbled = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"
garbled = garbled [::-2]

message = garbled
print message


#2

You have to save it to message variable directly,as instruction says.

Instruction says..

Use list slicing to extract the message and save it to a variable called message

(I think it throws error beacuse youre not following exact instructions)


#3

Boom worked:

garbled = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"
message = garbled[::-2]

Thanks for that, been staring at it for like 10 minutes trying to find my mistake


#4

You can edit your final code here so no one copies your solution :wink:


#5

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