This is my code, with some added prints for troubleshooting. It behaves exactly as I expect it to, yet I get an error when submitting saying that: “Oops, try again. remove_duplicates() resulted in an error: list index out of range”
I have tried running it on my debian server to doublecheck and I get no errors. It behaves exactly as expected and returns a list of numbers without any duplicates.
def remove_duplicates(x): l = len(x) print "length of x is: ", l newlist = [x] counter = 0 while counter < l -1: counter += 1 print "counter:", counter if x[counter] not in newlist: newlist.append(x[counter]) print x[counter], "does not exist in list and is added to list " else: print x[counter], "exists in list" print newlist return newlist print remove_duplicates([6,8,122,2,18,6,8,122,2,18])