DEV Community

Discussion on: 6 Python Easy Tricks for beginners

xanderyzwich profile image
Corey McCarty

That technique for reversing a string works for lists too. It's the slice operator where list_name[start:end:step] gives you the elements from start to end - 1 and step can allow you to grab every second or third element. -1 in this context tells it to start at the end because it's negative and use step size of one.