17. List Slicing - Advanced Question


Hey everyone.

I got it, the solution is:

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

The thing is: I got that by randomly trying stuff. I didn't see that every second letter is an "X". I thought the challenge was not only to read the statement backwards while just printing every second letter, but to print the statement backwards while deleting every X.

Now the job is done, but I still wonder how I can do what I thought I should do. So, can anyone explain how I could get the reversed message without X's?


And I just saw the next task ... nevermind. xD


garbled.translate(None, 'X')
removes all 'X'


thanks @boardrockstar90452 ...never thought like that before..nice sharing..:grin: