Looping in reverse PREMIUM

Series: Looping
Trey Hunner smiling in a t-shirt against a yellow wall
Trey Hunner
4 min. read 3 min. video Python 3.8—3.12

How can you loop over an iterable in reverse?

Reversing sequences with slicing

If you're working with a list, a string, or any other sequence in Python, you can reverse that sequence using Python's slicing syntax:


A Python Tip Every Week

Need to fill-in gaps in your Python skills? I send weekly emails designed to do just that.