14/15 remove_duplicates


Hi, on line #13, I understand the “-1” means “previous element” but how does the program know to move on to the NEXT previous element. I guess generally speaking I don’t understand the logic of line #13 so if anyone could elaborate a bit it would be greatly appreciated.


It actually means the first index from the right.

Your code is attempting to narrow down to unique values in the output by comparing ordinals in a sorted list. In principle this is sound logic except for one major flaw, it changes the order of the original inputs, rather than just remove duplicates from left to right.


Ah ok, first index from the right. Is this something built into python? As in, whenever you put a negative ONE it will mean automatically “first index from the right”?


The negative sign indicates right to left. [-3] is third index from the right, and so on.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.