Remove duplicates


Traceback (most recent call last):
File "python", line 7, in
File "python", line 2, in remove_duplicates
TypeError: 'int' object is not iterable

it should work, but I don't know what's wrong with my code.

def remove_duplicates(items):
    for i in len(items):
        for j in (i+1,len(items),1):
            if items[j] == items[i]:
    return items


It tells you the line and the problem (can't iterate through an int, isn't an iterable value like list or string)


This works perfectly
def remove_duplicates(items):
for val in items:
if val not in a:
return a


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