I got following task: create a function that will receive as argument a list of different elements and return a list of original elements (count of each element in list should be not more than 1). Order of elements should remain. Like below:
[1, 1.0, '1', -1, 1] # input
[1, 1.0, '1', -1] # output
I tried
def original_list(*a):
b=[]
for i in a:
if i not in b:
b.append(i)
return b
but got [1, '1', -1]
in return as 1==1.0
is True
. So how to force Python to "distinguish" int and float elements of the same value and get correct output list?