for loop to check for duplicates in array python code example
Example 1: python check for duplicate
def checkDuplicate(user):
if len(set(user)) < len(user):
return True
return False
Example 2: check list for duplicate values python
a = [1,2,3,2,1,5,6,5,5,5]
import collections
print([item for item, count in collections.Counter(a).items() if count > 1])
## [1, 2, 5]