Removing dupilcates- Using double loop ? ><` Please help ><`


I tried removing the duplicates using a double loop ><`

def remove_duplicates(numbers):
    for i in range(0,len(numbers)):
        for j in range(1,len(numbers)+1):
            if(numbers[j] == numbers(i)):
    return noDuplicate

Can it work using a double loop ? ><` .



Yes, it can.

Do I recommend it. No.

You already have the concept down but using the second loop is just wasting resources.

You should just simplify it to.

Python Code:

def remove_duplicates(aList):
    tmp = []
    for item in aList:
        if item not in tmp:
    return tmp

Or a single line,

Python Code:

def remove_duplicates(aList):
    return list(set(aList))

The above does not respect order mind you, but it is fast.

As always, as the programmer it is up to you on how you will handle something. If you need additional help feel free to ask.


Thank you for explaining it to me :slight_smile: I really appreciate it :slight_smile: :slight_smile: . Your explanation really helped me :slight_smile: .I will try to make the double loop work when I do I`ll show you the code again :relaxed: I will try not to trouble you too much :). Thank you for taking time to help me :slight_smile: .Have a great day!!! :grin: