List Slicing


#1


I dont understand why it is working

It should not work


Replace this line with your code. 

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


#2

does it not count space when we are shifting backwards?


#3

It does consider spaces to have the same status as all the other characters. The spaces will appear in the solution where they are appropriate.


#4

OKay now i understand..


#5

spaces are counted, you can see this by slightly modifying the code:

garbled = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"
index = len(garbled) -1
while index > 0:
    print garbled[index]
    index -= 2

#6

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