Code:
def remove_duplicates(inpt):
res = []
for num in inpt:
if num not in res:
res.append(num)
return res
print remove_duplicates([1, 2, 1, 2, 3, 3, 4, 6, 4, 6])
print remove_duplicates([10, 15, 10, 15])
print remove_duplicates([4, 4, 5, 5])
Output:
[1, 2, 3, 4, 6]
[10, 15]
[4, 5]
Once I complete a task, I often check the solution afterwards to see if anything can be done better.
However, this time around the solution appeared a bit overkill to me.
Is something wrong with the approach I went with above?