Remove Duplicates


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/2/4?curriculum_id=4f89dab3d788890003000096#


I'm getting this error message:
Oops, try again. remove_duplicates([]) resulted in an error: list index out of range

With the following code:
def remove_duplicates(zz):
new = []
new.append(zz[0])
for i in range(len(zz)):

    if zz[i] not in new:
        new.append(zz[i])


return new

I don't know how that is an error, as this code works on other shells. I don't think that the range of len(zz) should possibly give me an error... and I'm not modifying the list 'zz' at all.

Please help?
Thanks


Replace this line with your code.


#2

The above line will raise an error if the inputs are an empty list, as indicated by the error message.

if not len(zz) return []
new = []
for x in zz:
    new.append[x]

#4