Python Slicing and Reversing — Visual
Published in
Dec 15, 2020
Pictures help when trying to understand slicing, especially when using negative indexes along with positive indexes.
String sample
1. str[:0:-1]
2. str[:3:-1]
3. str[:2:-1]
4. str[-2:-6:-1]
5. str[-4:-1:-1]
6. str[-4:1:-1]
7. str[-3:1:-1]
8. str[-4:-1:]
9. str[-4:2:]
10. str[-2:-1:]
11. str[::-1]
Originally published at https://github.com/vidyabhandary.