I have looked around in other posts and haven't been able to come to a solution for this. I have a function that needs to be recursively called using an itertools expression in order to return a tuple that has unique elements with it's order preserved.
for instance:
def function(list):
return list and (list[0],) + function(some_itertools_expression)
given example: function([1, 7, 7, 9, 0, 1])
should return (1, 7, 9, 0)
I've tried using:
return list and (list[0],) + function(tuple([itertools.groupby(list)][:len(list)]))
but I end up running into RecursionError: maximum recursion depth exceeded
. How can I solve this without getting the max recursion depth error?