+ 3

I want to sort numbers in odd even pair but its printing even odd pair

n=int(input()) arr=list(map(int,input().split())) z=[] for i in range(len(arr)): if arr[i]%2!=0: z.append(arr[i]) else: z.append(arr[i]) if len(arr)%2!=0: z.append(0) print(*z)

10th Mar 2022, 3:10 PM
syed fahad
syed fahad - avatar
4 Answers
+ 3
syed fahad , it is not quite clear what you want to achieve. please make us a sample for input numbers, and what they should look like after sorting. thanks!
10th Mar 2022, 4:23 PM
Lothar
Lothar - avatar
+ 1
You're looking for something like this? https://code.sololearn.com/cmEfuc5wrgUH/?ref=app
10th Mar 2022, 4:48 PM
Simba
Simba - avatar
+ 1
Not clear! Write down 1. input 2. output
10th Mar 2022, 5:07 PM
Shadoff
Shadoff - avatar
0
Want to print in the same order
10th Mar 2022, 3:26 PM
Online Mining junction
Online Mining junction - avatar