0

How this slicing works ?

name = "santhosh" print(name[7:0:-1]) Output : hsohtna

1st Apr 2021, 12:49 PM
T.K.SANTHOSH
T.K.SANTHOSH - avatar
2 ответов
+ 8
string[start:stop:step] you understand indexing? its basically counting every character in a string, but it starts at 0. -1 is the last value. start - what index to start counting from (included) stop - what index to stop counting at (excluded) step - DEFAULT = 1. How to get from the start to the stop. Anything negative just means backwards.
1st Apr 2021, 1:01 PM
Slick
Slick - avatar
+ 2
Thank you for your answer Slick
1st Apr 2021, 1:21 PM
T.K.SANTHOSH
T.K.SANTHOSH - avatar