What I don't understand is why the removal process doesn't stop before the last copy of the digit is removed. I would think my while loop would handle that by exiting before it can remove the last copy but apparently it doesn't, or it loops too many times, or something. I'm muddled up and can't figure out where the logical errors are.
I peeked at the hint and saw there was a much easier way to do this exercise, but I'd like to understand why my method fails. Thanks!
def remove_duplicates(multiples): oncelist= for x in multiples: oncelist.append(x) count=0 for x in multiples: print oncelist for y in oncelist: if x==y: count+=1 print count while count >=1: for y in oncelist: if x==y: count-=1 oncelist.remove(y) return oncelist remove_duplicates([3,3]) remove_duplicates([4,5,5,4])