## Reverse the second half of list elements in python

### Description

```Python Program to get list size n and n elements of list, then reverse the second n/2 elements.
Input:
5
5 7 9 3 1
Output:
5 7 1 3 9```

### Solution

```l=list(map(int,input("Enter Numbers:").split()))
start=len(l)//2
stop=len(l)-1
while(start<stop):
l[start],l[stop]=l[stop],l[start]
start+=1
stop-=1
print(l)

```

We are Teaching "Web Development using Python" through Online.

View Tutor Profile and Course Syllabus

### Explanation

```initialize start to first location of list and stop to last location of list using
start=len(l)/2
stop=len(l)-1

swap the elements in location start and stop, then increment start by 1 and decrement stop by 1.
l[start],l[stop]=l[stop],l[start]

repeat the above step till start is less than stop```

#### Author - Ramesh P Natarajan

Software Developer and Technology Trainer, very much passionate in the field of Software Application Development, Machine Learning and Search Engine Optimization.

Write to: [email protected]

### Interesting Pattern Programs: for more Patterns

```Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution```
```Input:
5
Output:
*
***
*****
*******
*********
*******
*****
***
*Solution```
```Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution```
```Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution```
```Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution```
```Input:
5
Output:
*********
*******
*****
***
*
***
*****
*******
*********Solution```