#列表1
list1 = ['張三', '李四', '王五', '老二']
#列表2
list2 = ['張三', '李四', '老二', '王七']
a = [x for x in list1 if x in list2] #兩個列表表都存在
b = [y for y in (list1 + list2) if y not in a] #兩個列表中的不同元素
print('a的值為:',a)
print('b的值為:',b)
c = [x for x in list1 if x not in list2] #在list1列表中而不在list2列表中
d = [y for y in list2 if y not in list1] #在list2列表中而不在list1列表中
print('c的值為:',c)
print('d的值為:',d)