Here's a simple def/function to zip() the two lists and then get max() and store it into a new list3 and returned:list1=[2,54,31,6,42]list2=[4,98,43,3,2]def function(list1,list2): #def returns 3rd list list3 = [max(value) for value in zip(list1, list2)] return list3print(function(list1,list2)) # call def named function to print输出:[4, 98, 43, 6, 42] 这篇关于Python.比较2个列表中的数字并找到最大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 10:59