List Reversal in Python


Reverse a list in Python.

Source Code

numbers = [1, 2, 3, 4, 5]
numbers.reverse()  # In-place reversal
print(numbers)

# Using slicing for a new reversed list
reversed_numbers = numbers[::-1]
print(reversed_numbers)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments