Skip to content

Reverse a list in Python using slicing

Advertisements

nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print nums[::-1]
#[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.