Python program to Reverse a given list in-place
To reverse a list in-place in Python, you can use list slicing or the built-in `reverse()` method. Here's a Python program using both methods:
Using list slicing:
```python
def reverse_list_in_place(lst):
lst[:] = lst[::-1]
# Example usage:
my_list = [1, 2, 3, 4, 5]
reverse_list_in_place(my_list)
print("Reversed list:", my_list)
```
Using the `reverse()` method:
```python
def reverse_list_in_place(lst):
lst.reverse()
# Example usage:
my_list = [1, 2, 3, 4, 5]
reverse_list_in_place(my_list)
print("Reversed list:", my_list)
```
Both of these programs will output:
```
Reversed list: [5, 4, 3, 2, 1]
```
Both methods modify the original list in-place, reversing its elements.