【发布时间】:2017-02-06 18:45:54
【问题描述】:
def insertion_sort(list):
for index in range(1,len(list)):
value=list[index]
i=index-1
while i>=0:
if value<list[1]:
list[i+1]=list[i] # shift no in slot i to i+1
list[i]=value # shift value left into slot i
i=i-1
else:
break
k =input("enter no of elements")
print(insertion_sort(k))
【问题讨论】:
-
你的函数没有返回任何东西,所以我不确定你期望打印什么。
-
非常感谢朋友!
标签: python loops insertion-sort