I am having a problem converting a set to a list using Python 3.4.4. I am unsuccessfully attempting the list_duplicates function in Find and list duplicates in a list?:
def list_duplicates(seq):
seen = set()
seen_add = seen.add
seen_twice = set( x for x in seq if x in seen or seen_add(x) )
return list( seen_twice )
a = [1,2,3,2,1,5,6,5,5,5]
list_duplicates(a) # yields [1, 2, 5]
I recieve the error "'tuple' object is not callable" at the line return list(seen_twice)
I get an identical error with the simpler example
a = set(["Blah", "Hello"])
a = list(a)
Is this a particular issue with Python 3.4 or am I doing something obviously wrong?