numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# using tuple assignment to reverse the list
numbers = tuple(numbers)
numbers = numbers[::-1]
numbers = list(numbers)
print("Reversed numbers:", numbers)
Reversed numbers: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
tuple()
function, and use tuple assignment to reverse the order of the elements in the tuple using the slicing operator [::-1]
. Finally, we convert the tuple back to a list using the list()
function and print the reversed list.