python - Remove duplicates from list of lists -
i have list containing ~300 lists, of them duplicates , remove them. i've tried:
cleanlist = [cleanlist.append(x) x in oldlist if x not in cleanlist] but keeps throwing runtimeerror: maximum recursion depth exceeded in comparison @ me. tried sys.setrecursionlimit(1500) didn't help.
what's better way this?
you're adding bunch of stuff cleanlist based on whether it's in cleanlist (which doesn't exist yet), , saving value returned append() operation (which none) cleanlist. not end well.
a better way old-fashioned loop construct:
cleanlist = [] x in oldlist: if x not in cleanlist: cleanlist.append(x)
Comments
Post a Comment