My code works, but codecademy won't accept it. I wrote this not knowing that I can use "if not in" to remove the duplicates.
Again, my code outputs the correctly: no, duplicates. But this is what codecademy says:
Oops, try again. remove_duplicates() resulted in an error: list index out of range
Could someone please help me identify why I get what codecademy says above.
def remove_duplicates(the_list): selector = # this list is for storing non-duplicates of the pivot pure_list = #this is where the purified pivot's are stored pivot_count = 0 pivot = the_list[pivot_count] #this is just so i can keep looping while len(the_list) != 0: #this will loop through the size of the_list for i in range(len(the_list)): #compares the first entry to the every entry #if the same do nothing; if not the same, append if pivot != the_list[i]: selector.append(the_list[i]) #his is to update the_list #updating the_list means getting rid of the pivot's duplicates the_list = selector selector =  #this clears the selector the pivot's non_duplicates can be stored again pure_list.append(pivot)#adds the pivot that was purified to pure_list if pivot_count == len(the_list):#unfortunately, I don't know anyother way to stop my whil loop,but this break else: pivot = the_list[pivot_count]#pivot becomes the 1st item of the updated the_list return pure_list print remove_duplicates([5,5,2,5,5,5,23,5,3,2,23,6,6,6,6])