my_string = “This is MY string!”
print(my_string[18:0:-1])
And not in this …
print(my_string[::-1])
What is the difference in logic ??
my_string = “This is MY string!”
print(my_string[18:0:-1])
And not in this …
print(my_string[::-1])
What is the difference in logic ??
We have the following notation in python for string slicing:
[ <first element to include> : <first element to exclude> : <step> ]
So, if you want to include T in string, then either use
print(my_string[18:0:-1]) OR
print(my_string[18::-1])