← All tips

Python: reverse a list safely

pythonbasics

Use slicing to get a reversed copy.

nums = [1, 2, 3]
rev = nums[::-1]
print(nums, rev)