Nov-20-2020, 01:32 PM
Greetings,
I am new to the Python language; however, I have experience in other OOP languages. I have a question based on Python substring syntax.
The following code
My only reasoning behind this is, it works differently when you are counting down then when moving forward through the string?
Everything works as intended when I am counting up.
Any help would be greatly appreciated,
Regards,
Matt
I am new to the Python language; however, I have experience in other OOP languages. I have a question based on Python substring syntax.
The following code
my_string = "This is MY string!" print(my_string[13:2:-1])generates the return string
rts YM si sI am a little confused at what this substring returns. I base it on the middle parameter '2', which should be 2-1 as I am told, as the following syntax would suggest:
[start:end-1:steps]How come this does not seem to be working here? If the previous syntax is correct, it would have included the 'i' in the return string
rts YM si s, instead it only includes the 's'.
My only reasoning behind this is, it works differently when you are counting down then when moving forward through the string?
Everything works as intended when I am counting up.
Any help would be greatly appreciated,
Regards,
Matt