python求助
list1 = ['1.just do it', '2.一切皆有可能', '3.让编程改变世界','4.Impossible is Nothing']list2 = ['4.阿迪达斯', '3.李宁', '2.鱼c工作室', '1.耐克']
list3 = []
for slogan in list1:
for name in list2:
if slogan == name:
list3.append((name + ':' + slogan))
for each in list3:
print(each)
这个是什么意思啊 就是根据数字来找匹配呀 本帖最后由 myqf123 于 2021-11-11 18:06 编辑
list1 = ['1.just do it', '2.一切皆有可能', '3.让编程改变世界','4.Impossible is Nothing']
list2 = ['4.阿迪达斯', '3.李宁', '2.鱼c工作室', '1.耐克']
list3 = []
for slogan in list1:
for name in list2: #这两次遍历是为了匹配前面的数字
if slogan == name: #判断数字一样的组合在一起,并添加到列表3里
list3.append((name + ':' + slogan))
for each in list3: #然后遍历列表3,并打印里边匹配好的元素
print(each)
页:
[1]