Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Previous code
- a = list(map(int, raw_input().split()))
- for i in a:
- if a.count(i) == 1:
- print i
- break
- // Current code
- from collections import Counter
- a = list(map(int, raw_input().split()))
- b = Counter(a)
- onlies = [k for k,v in b if v == 1]
- print onlies
- # one way using sets
- present = set()
- morelies = set()
- for i in a:
- if i in present:
- morelies.add(i)
- else:
- present.add(i)
- onlies = present - morelies
- print(onlies)
- # another way using sets
- onlies = set()
- morelies = set()
- for i in a:
- if i in morelies:
- pass
- elif i in onlies:
- morelies.add(i)
- onlies.remove(i)
- else:
- onlies.add(i)
- print(onlies)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement