Use of string to print ?
St="hello to all my friends in python"
Print (St[1:3:-1])
IT print blank
Use of string to print ?
St="hello to all my friends in python"
Print (St[1:3:-1])
IT print blank
In print function you're slicing the string from 1st index to less than 3rd index. But you're using a negative step (which means reverse). So it won't print anything. If you use positive step then it will print el
.
Here is the corrected code:
print(St[1:3:1])
As you are reversing the string (-1 in the slicing), you should also treat the elements of the string reversed, so 3 comes before 1. Try the following:
print(St[3:1:-1])