String slicing specifies how to cut the string. Used in square brackets, the numbers are written in order of
[Position of the letter where it should start : Position where it should stop : Jumping]
(
Important note : Slicing starts from 0 ,i.e., the first letter is 0, second is 1 etc.)
Let's take your example
my_string = "0123456789"
print(my_string[3])
Here, you have written 3, so it will display the the third element, which is 3
my_string = "0123456789"
print(my_string[3:5])
In the above line, the output will be 34. It won't display 345, as it just displays the first number and the numbers in between , not the ending one
my_string = "0123456789"
print(my_string[3:9:2])
Here, it will display 357 as the "2" in the end makes the string jump by 2 - if it was 1, it would be 345678
Note - default value is always set as 1
Now let's see your problem -
my_string = "0123456789"
print(my_string[3: 2: 4])
There is a problem in this :
- You can't reverse a string by doing the think you have done - to reverse you got to do like this
str1 = "abcdefghijk"
print(str1[::-1])
So, these are the reasons your output is coming blank