-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathList_sort.py
36 lines (32 loc) · 887 Bytes
/
List_sort.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def list_sort(list, list_len):
l, r = 0, list_len - 1
k = 0
flag = True
while flag:
flag = False
try:
count = 0
list = []
for i in range(0, 5):
number = int(round(float(input('Please enter a number: '))))
list.append(number)
print(list)
except ValueError:
print("Enter a Valid Input")
flag = True
while (l < r):
while (list[l] % 2 != 0):
l += 1
while (list[r] % 2 == 0 and l < r):
r -= 1
if (l < r):
list[l], list[r] = list[r], list[l]
odd = list[:k]
even = list[k:]
odd.sort()
even.sort()
odd.extend(even)
return odd
list_len = 6
kk = list_sort()
print("xhs", kk)