Aim:
Write a function dups to find all duplicates in the list.
Program:
def FindDuplicates(list): for i in list: count = list.count(i) if count > 1: print ('There are duplicates in list') return True print ('There are no duplicates in list' ) return False a = [8, 64, 16, 32, 4, 24] b = [2,2,3,6,78,65,4,4,5] print(a) FindDuplicates(a) print(b) FindDuplicates(b)
Execution:
[8, 64, 16, 32, 4, 24] There are no duplicates in list [2, 2, 3, 6, 78, 65, 4, 4, 5] There are duplicates in list