- 定义函数
find_unique()
,它接受一个列表作为参数。 - 在函数内部,找出列表中只出现一次的数字。
- 以列表中的出现的顺序返回唯一的数字
示例输入
1 2 2 3 4 4 5 5
示例输出
[1, 3]
def find_unique(lst):
return list({i:lst.count(i) for i in lst if lst.count(i)%2==1}.keys())
# 获取用户输入并转为数字列表
numbers = list(map(int, input().split()))
# 调用函数
print(find_unique(numbers))