Articles(Page 4)

How to reverse a range in Python (with examples)

⤳ Sometimes you need to reverse a range in Python to iterate over a list of items in reverse order. This quick guide explores two popular methods of reversing ranges (or any iterator) in Python. Before we start, let’s quickly review Python’s range() function. A range ...