Actual exercise

Oops,try again remove_duplicates([4, 5, 5, 4]) returned '[4, 5]' instead of [4, 5]

Dont know what error trying to explain

def remove_duplicates(integer):
    integer = str(integer)
    result = ""
    for i in integer:
        if i not in result:
            result += i
    return result


You returned the result as a string, rather than the list needed. :slight_smile:


Yes you are right but as always codecademy does it brought another error even though it worked
Oops, try again.remove_duplicates([4, 5, 5, 4]) resulted in an error: 'int' object is not iterable
then i changed it as a string
integer = str(integer)
then one more problem
Oops, try again.remove_duplicates([4, 5, 5, 4]) returned ['[', '4', ',', ' ', '5', ']'] instead of [4, 5]
i'm done


they want you to return a list not a string so first you need to define your result as an empty list:
result =[]
please correct that and check for the error. is it the full code you have there?


already tried it got the error i mentioned in my second post.


you should delete the integer variable, and you should set the result variable in an empty list. And in your if clause you have to put result.append(i), it worked for me

def remove_duplicates(nums):
    nums2 = []
    for n in nums:
        if n not in nums2:
    return nums2

Hope it helps you :slight_smile: