14. remove_duplicates Cant make code work



It doesnt return any value

To return the values............So i just noticed now that the problem was the last for ,wouldnt append because there was no key with 1 value , all had at least 2 my bad, the post can be locked

def remove_duplicates(lista):
    contagens = { } #dict with number and the number of apparitions
    listafinal = [] #final list to return
    for itens in lista:
        for elementos in contagens: 
            if itens == elementos:
                contagens[elementos] += 1
    for i in contagens:
        if contagens[i] == 1:
    return listafinal


creating the contagens goes pretty well, but lets say i have this list:


you will get:

{4: 2,5: 2}

then i don't understand this:

    for i in contagens:
        if contagens[i] == 1:

why an if condition? each key in your dictionary will be unique, you can just append it to the list. You can just remove the if condition


I didnt realize that the if was useless until too late .


But did you resolve it?


Yes i did, thanks , i must had brainlag when i tried that if