Generation

translateMon, 17 Apr 2023

lst1=[1,2,3,4,2,4,5,2] lst2=[2,1,4,5,2,3] 找出两个列表的相同元素、找出两个列表的不同元素,并打印结果。

lst1 = [1, 2, 3, 4, 2, 4, 5, 2] lst2 = [2, 1, 4, 5, 2, 3] print([x for x in lst1 if x in lst2]) print([x for x in lst1 if x not in lst2])

Questions about programming?Chat with your personal AI assistant