Hi Stephen, we can create a new empty list and iterate on first list which has non-unique values and check if an item is not in second list - if so append the item to second list. This approach also seems to maintain the order of the first list and creates unique values.
This was excellent thank you. I have often used sets to dedupe, but never used a dictionary to.
Great tip!
Sets are the ideal route if you don’t care about order (and all elements are hashable)
Hi Stephen, we can create a new empty list and iterate on first list which has non-unique values and check if an item is not in second list - if so append the item to second list. This approach also seems to maintain the order of the first list and creates unique values.
Indeed, that works too. But going through dict.fromkeys() will be faster (I believe).