摘要:
#s=1!+2!+3!+…..+n! from functools import reduce def factorial(n): result=0 for i in range(1,n+1): result+=reduce(lambda x,y:x*y,list(range(1,i+1))) print('%s的阶乘加和结果为:%s'%(i,... 阅读全文
摘要:
#列表去重 #方法1: l = [1,2,5,2,2,6,5,6,6,1,2,8] print(l) #方法1: l = [1,2,5,2,2,6,5,6,6,1,2,8] l_new=[] for i in l: if i not in l_new: l_new.append(i) print('l_new',l_new,n) #方法2: l = [1,2,5,... 阅读全文