jeapedu 129 集合的習題3

链接: https://pan.baidu.com/s/1eI0ybsXKhU3Zrow8u9fCPA 密码: sv26

# 3 find different item in two tuple
t1 = tuple("123456")
t2 = tuple("245689")
print(t1)
print(t2)
s1 = set(t1)
s2 = set(t2)
print(s1)
print(s2)
d12 = s1.difference(s2)
print(d12)
d21 = s2.difference(s1)
print(d21)
for x in d21:
    d12.add(x)
print(d12)

print(t1)
print(t2)
temp = []
for x in t1:
    if x not in t2:
        temp.append(x)
for x in t2:
    if x not in t1:
        temp.append(x)
print(temp)
t = tuple(temp)
print(t)
阅读更多
想对作者说点什么?

博主推荐

换一批

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