给定两行输入,每行代表一组元素,每行的元素间用空格分开,求两组中非公共的元素。
给定两行输入,每行代表一组元素,每行的元素间用空格分开,求两组中非公共的元素。
收起
代码如下,有帮助的话记得采纳一下哦!
- M = list(map(str,input().split()))
- N = list(map(str,input().split()))
- not_dup = []
- for each in M:
- if each not in N and each not in not_dup:
- not_dup.append(each)
- for each in N:
- if each not in M and each not in not_dup:
- not_dup.append(each)
- print(' '.join(not_dup))
报告相同问题?