DEV Community

loading...

Discussion on: Daily Challenge #273 - Remove Duplicates

Collapse
codeperfectplus profile image
Deepak Raj • Edited

This solution is in python

def Remove(duplicate): 
    final_list = [] 
    for num in duplicate: 
        if num not in final_list: 
            final_list.append(num) 
    return final_list

print(Remove([3, 4, 4, 3, 6, 3]))

output

[3, 4, 6]
Collapse
rafaacioly profile image
Rafael Acioly

Hi, you could have use the set method, like this:

dev.to/rafaacioly/comment/12l2j

:)

Collapse
gwelr profile image
Grégoire Welraeds

is
[3, 4, 6]
not
[4, 6, 3]
which is the expected answer

Collapse
maskedman99 profile image
Rohit Prasad

Fixed it

def Remove(duplicate):
    final = []

    for i in range(len(duplicate)):
        if duplicate[i] not in duplicate[i+1:]:
            final.append(duplicate[i])

    return final

x = input("Enter the integers: ")
x = x.split()

print(Remove(x))