关于Python的问题

令随机数种子为 1,随机生成范围在 0 到 10 万之间的 1 万个整数,为列表 A,随机生成 范围在 5 万-10 万之间的 1 万个整数,为列表 B,求 A 与 B 相同整数的集合,A 与 B 不同整 数的集合,A 单独有的整数的集合,B 单独有的整数的集合。


from random import sample

list_a = sample(range(0,100000),10000)
list_b = sample(range(50000,100000),10000)

xiangtong = []
butong = []
only_a = []
only_b = []

for i in list_a:
    if i in list_b:
        xiangtong.append(i)
    elif i not in list_b:
        only_a.append(i)
        butong.append(i)

for j in list_b:
    if j not in list_a:
        only_b.append(j)
        butong.append(j)

print(f"列表A和列表B相同的整数是:{xiangtong}")
print(f"列表A和列表B不同的整数是:{butong}")
print(f"列表A独有的整数是:{only_a}")
print(f"列表B独有的整数是:{only_b}")