Crag的博客

自学编程

jeapedu 130 集合的習題4

链接: https://pan.baidu.com/s/1egip4ulMGaCKuLzCAbjKlA 密码: si74

# 5 combine two lists, duplicate
li1 = [1, 3, 5, 6]
li2 = [2, 3, 6, 9, 10]
l = li1 + li2
lss = set(l)
ll = list(lss)
print(ll)
ls1 = set(li1)
ls2 = set(li2)
print(ls1)
print(ls2)
lss = ls1.union(ls2)
print(lss)
ll = list(lss)
print(ll)

print(ls1)
print(ls2)
t1 = ls1.difference(ls2)
t2 = ls2.difference(ls1)
t3 = ls1.intersection(ls2)
t = t1.union(t2).union(t3)
print(t)
t1 = t1.union(t2, t3)
print(t1)
阅读更多
个人分类: jeapedu
上一篇jeapedu 129 集合的習題3
下一篇jeapedu 131 集合的習題4方法二
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭