I have a little code that takes a list of objects, and only outputs the items in the list that are unique.
This is my code
def only_once(a):
retu
[I'm assuming that you're also user1744238 and user1744316 -- please pick a username and stick to it, that way it's easier to check to see what variants of a question you've asked and what you've already tried.]
One set-based approach is to use two sets as a counter. You only care about whether you've seen something once or more than once. For example, here's an easy-to-explain approach:
once
and more
. once
. once
and add it to more
. once
. once
set so you don't output the same element twice.This gives me:
In [49]: f([1,4,6,7,3,2,4,5,7,5,6])
Out[49]: [1, 3, 2]