- #1
adjacent
Gold Member
- 1,552
- 63
Here is a python function to check whether a given list or string contains duplicate values:
But I am sure this approach will be slow for large lists. Is there any other, faster way to do this?
Code:
def has_duplicates(x):
t = []
for i in x:
if i not in t:
t.append(i)
if t != list(x):
return True
else:
return False
But I am sure this approach will be slow for large lists. Is there any other, faster way to do this?