Created
October 13, 2016 22:58
-
-
Save kwekuboateng/bf65dbec671410f6a458718e03b6a064 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sorting_nums(item): | |
item = sorted(item) | |
len_item = len(item) | |
middle = len_item // 2 | |
new_item = [] | |
for i in range(middle): | |
new_item.append(item[i]) | |
new_item.append(item[-1-i]) | |
if len_item % 2 == 1: | |
new_item.append(item[middle]) | |
return new_item | |
a = [1,5,4,6,7,2,3] | |
print(sorting_nums(a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment