Practice Markes Perfect_remove_duplicates


Hi Master,
My code can pass the test, but i don't think it's good, is it right ?

Code is here:

def remove_duplicates(x):
    l = []
    y = x
    for i in x:
        z = i
    return z
    for e in y:
        if e == z:
            l = y.remove(e)
    return l
z = [1,2,2]
print remove_duplicates(z)


There is something wrong about this program.
This should have halted after first loop as return is there.
if you test this code on .. [1,1,2,2] it returns 2 but it has to return [1,2].
This o/p w.r.t to code is right but w.r.t exercise it should not be passed.
(Point me out if I'm wrong about this)


yes ,you are right, i will be to change my code.


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