新手求教个问题list1里是数字1到100list2里是数字
python吧
全部回复
仅看楼主
level 2
新手求教个问题
list1里是数字1到100
list2里是数字3,15,22(数字我随便写的)
怎样让list1里的1到100这些数字循环对应加上list2里的数字,就是1
+3
,2+15,3+22,4+3,5+15,6+22,……这样循环下去再把结果加到一个新列表中
2020年04月01日 07点04分 1
level 6
大哥,你没听说过循环可以嵌套的么[黑线]
2020年04月01日 08点04分 2
level 1
Python方式:[(i+j) for i,j in zip(list1,list2)]
2020年04月01日 08点04分 3
用 zip ,数据可能丢失的[汗],除非两个列表长度一样
2020年04月03日 03点04分
level 11
list1 = list(range(1, 101))
list2 = [3, 15, 22]
lg = len(list2)
list3 = []
for n, x in enumerate(list1):
i = n % lg
list3.append(x + list2[i])
print(list3)
2020年04月01日 08点04分 4
百度格式有问题,倒数2-3行缩进
2020年04月01日 08点04分
@Critic2012 谢大佬[真棒]
2020年04月03日 02点04分
level 8
同学,有问题可以来我小店咨询,简单的都可以无偿帮您解答的【python爬虫spss数据分析学生代做matlab程序r语言https://m.tb.cn/h.V4scFDU 需要代做也可以哦
2020年04月03日 22点04分 5
1