Just looking at line 3,4 and 5 in my code below:-
def remove_duplicates(lst): i = 0 # result =  # result += lst result = lst while i < (len(result)-1): n = i + 1 while n < len(result): if result[i] == result[n]: del(result[n]) else: n += 1 i += 1 print lst print result return result remove_duplicates([4,5,5,4])
When I run the code as is, the two printed lists are [4,5] and [4,5] respectively, that is, altering my 'copy' of the passed parameter, is altering the parameter too!! If I comment line 5 out and uncomment 3,4 it works fine. Can anyone explain this behaviour??