List Slicing


#1

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

output:
I am the secret message!
None

error:
Oops, try again. Your message doesn't look quite right; instead of "IX XaXmX XtXhXeX XsXeXcXrXeXtX XmXeXsXsXaXgXeX!", it should be "I am the secret message!"


#2

the message variable should contain the correct translation. it doesn't, the output appears correct, because when you print, you apply more list slicing


#4

so try the following

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


#5

yea, or you just use -2, that is even easier.


#6

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