r/pythonhelp • u/Ok_Minute_1156 • Jan 28 '22
a very noob question
i wrote these two lines:
>>> numbers = "123456789"
>>> numbers[-9:-1]
than it said '12345678' instead of '123456789'
what to do?
3
Upvotes
r/pythonhelp • u/Ok_Minute_1156 • Jan 28 '22
i wrote these two lines:
>>> numbers = "123456789"
>>> numbers[-9:-1]
than it said '12345678' instead of '123456789'
what to do?
0
u/ragnarok628 Jan 28 '22
By setting the 'start' and 'stop' sections, you just sliced it, you didn't reverse it. You want the 'step' section to be -1, you can leave the start and stop sections alone. So:
Should do what you want