# 14/15 - Code works on repl.it but not here

#1

CA just keeps telling me I'm modifying the input list...but I'm returning a totally different list. And I'm not looping through the list I'm modifying either. Help? I've seen some of the other solutions but I want to know why my idea isn't working.

def remove_duplicates(deDupeIn):

``````i = 0
deDupeThis = deDupeIn

while i < len(deDupeIn):

deDuperMem = deDupeIn[i]
j = i + 1
while j < len(deDupeIn):
if deDupeThis[j] == deDuperMem:
del deDupeThis[j]
j += 1
i += 1

return deDupeThis``````

#2

I figured it out. Though I'm still not sure why the list that was passed in was being modified when I was editing the new list. But regardless, this worked

def remove_duplicates(deDupeIn):

``````i = 0
deDupeThis = []
inputLength = len(deDupeIn)

while i < inputLength:
deDupeThis.append(deDupeIn[i])
i += 1

i = 0

changingLength = len(deDupeThis)

while i < changingLength:

deDuperMem = deDupeThis[i]
print(deDuperMem)
j = i + 1
while j < changingLength:
if deDupeThis[j] == deDuperMem:
del deDupeThis[j]
changingLength -= 1
j -= 1
j += 1
i += 1

return deDupeThis``````

That little j -= 1 eluded me for a while.