DEV Community

Discussion on: Python Loops Cheat Sheet

Collapse
 
moopet profile image
Ben Sinclair

Instead of doing range(1,6)[::-1] you can pass a negative step into the function itself like range(5,0,-1) which might be more readable depending on the context.

Collapse
 
shahzzoda profile image
Shahzoda D.

That is much more readable. Thank you for your insight!