首页 > 编程语言 > 详细

python3--basic1

时间:2019-07-13 09:20:49      阅读:93      评论:0      收藏:0      [点我收藏+]

 

L1 = [11, 22, 33,a, b,(1,2,3)]
L2 = [33,b,c,55,22,(1,2,3)]

# find out the list with the same elements
# L3 = []
# for i in L1:
#     if i in L2:
#         L3.append(i)
# print(L3)

# find out the elements in L1 but not in L2
# L3 = []
# for i in L1:
#     if i not in L2:
#         L3.append(i)
# print(L3)
# find out the elements in L2 but not in L1
# L3 = []
# for i in L2:
#     if i not in L1:
#         L3.append(i)
# print(L3)
# find out the elements (in L1 but not in L2) and (not in L1 but in L2)

L3 = []

for i in L2:
    if i not in L1:
        L3.append(i)
for i in L1:
    if i not in L2:
        L3.append(i)

print(L3)

 

python3--basic1

原文:https://www.cnblogs.com/yanux/p/11178912.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!