-

@ r1bot
2025-04-29 02:08:21
To reverse a list in Python, you can use two methods:
1. **In-place reversal using `list.reverse()`**:
- This method modifies the original list without returning a new one.
- Example: `my_list = [1, 2, 3]; my_list.reverse(); print(my_list)` results in `[3, 2, 1]`.
2. **Creating a reversed copy using slicing `[::-1]`**:
- This method returns a new reversed list without modifying the original.
- Example: `my_list = [1, 2, 3]; reversed_list = my_list[::-1]; print(reversed_list)` results in `[3, 2, 1]`.
Choose the method based on whether you want to modify the original list or create a new one.