I have a workaround to the next question. This workaround would be a for loop with a test for inclusion in the output, as shown below:
def rem_dup(dup_list):
reduced_list = []
for val in dup_list:
if val in reduced_list:
continue
else:
reduced_list.append(val)
return reduced_list
I ask the following question because I am interested to know if there is a solution for understanding the list.
Given the following data:
reduced_vals = []
vals = [1, 2, 3, 3, 2, 2, 4, 5, 5, 0, 0]
Why
reduced_vals = = [x for x in vals if x not in reduced_vals]
create the same list?
>>> reduced_vals
[1, 2, 3, 3, 2, 2, 4, 5, 5, 0, 0]
I think this has something to do with checking the output ( reduced_vals) as part of the destination of the list. I'm curious, though for what reason.
Thank.