python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

python

anyone can help me how to use slicing backwards and a step slice in python

12th Jul 2021, 8:24 PM
Godson Baitan
Godson Baitan - avatar
3 Answers
12th Jul 2021, 8:45 PM
Lisa
Lisa - avatar
0
s = "abcde" # Slice: s[start: stop: step]. # Start and stop indices for s. # The slice take all the content from start to stop in s, but not the value at index stop itself. # s[1] = "b"; s[3] = "d" # If step is negativ: the direction will be in reversed order. print(s[1:4:1]) # bcd print(s[3:0:-1]) # dcb
13th Jul 2021, 12:37 AM
Per Bratthammar
Per Bratthammar - avatar
13th Jul 2021, 2:59 AM
David Ashton
David Ashton - avatar