#14 Remove Duplicates Excercise


#1

It takes a great deal for me to come out and ask for help, but this tiny bit of code is bugging me immensely.

  • Error Message: "Oops, try again. remove_duplicates([4, 5, 5, 4]) resulted in an error: argument of type 'NoneType' is not iterable"

def remove_duplicates(nums):
    cleannums=[]
    for n in nums:
        if n not in cleannums:
            cleannums = cleannums.append(n)
    return cleannums


Thanks in advance.
Taylan U


#2

Remove the cleannums = in cleannums = cleannums.append(n). You are assigning the variable to the action done on the variable...which makes Python confused hence that error pops up.


#3

Well that solved it. +1 man.
I’m glad that this place exists for us.

@moderateurs this post can be closed at your earliest convenience.
Thanks to @datfatcat


#4

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