Remove_duplicates working correctly (maybe) not proving succcessful


#1



Stuck @ remove_duplicates


Prints as if correct output, won't count it as successful (sorry if its something stupid but I thought it might be something importiant...)



def remove_duplicates(numbers):
    results = numbers
    for num in numbers:
        if numbers.count(num) > 1:
            for i in range(1,numbers.count(num)):
                results.remove(num)
    return results


#2

Your new list in not in the correct order...


#4

this:

results = numbers

will make a variable referring to the same list, not make a copy of the list

Remove is a really difficult approach, are you certain you want to do this?

You might want to add some print statements, to see that too much gets removed


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.