I’ve dealt with this kind of issue many times, and a clean approach I often use is leveraging a set for tracking duplicates. It’s efficient and preserves the order of items in your list.
Here’s how you can do it:
lseparatedOrbList = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6]
seen = set()
unique_list = []
for item in lseparatedOrbList:
if item not in seen:
unique_list.append(item)
seen.add(item)
print(unique_list) # Output: [1, 2, 3, 4, 5, 6]
This ensures a straightforward way to achieve Python dedupe list functionality without modifying the original list during iteration.