I have a list of elements from 1 to n, (range(1, n + 1)
)
How should I swap odd greater elements with the even elements?
for example, if I have a list with elements [1,2,3]
the desired output will be [1,3,2]
because odd 3 is greater than even 2 .
example 2:
if list = [1,2,3,4,5]
the desired output will be
[1,3,2,5,4]
Here 2 will be swapped with 3 and 4 will be swapped with 5 but not with 3 because 3 is smaller than 4.