# 练习39:定义函数find_sum(li:list,sum:int),实现功能是对于任意数字列表,
# 找到列表中两两相加等于sum的数字
# 例如: num_list=[3,2,4,7,1] sum=5,返回列表[[3,2],[4,1] ]
# list2=[3,2,4,7,1]
# sum1=5
# def find_sum(li:list,sum:int):
# list1 = []
# for i in range(0,len(li)-1):
# for j in range(i+1,len(li)):
# if li[i] + li[j] == sum:
# list1.append([li[i],li[j]])
# return list1
# print(find_sum(list2,sum1))
# 练习40:while循环实现练习39
# def find_sum(li:list,sum:int):
# list1=[]
# i=0
# while i < len(li)-1:
# j=i+1
# while j<len(li):
# if li[i] + li[j] ==sum:
# list1.append([li[i],li[j]])
# j+=1
# i+=1
# return list1
# list2=[3,2,4,7,1]
# sum1=5
# print(find_sum(list2,sum1))