Oops, try again. Your remove_duplicates modifies the list that was passed to it. [4, 5, 5, 4] was modified to [5, 4]. Perhaps you should make a copy first!
def remove_duplicates(l): a=l t= r= for s in a: if s not in t: r.append(s) r.append(t) a.pop(0) b=a return b