def remove_duplicates(x): hola = x for i in range(len(hola)): n = len(hola)-1 while n > i: if hola[i] == hola[n]: del hola[i] n -= 1 return hola print remove_duplicates([1,2,2])
Hello! I thought that line hola = x will assure that x won''t change and any changes will be implemented only in hola list. But it looks like I was wrong. Can you explain me why and make my code better (beacuse it actually removes duplicates - the problem is "Perhaps you should make a copy first!")?