Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

program to print duplicates from a list of integers in python

lst = [ 3, 6, 9, 12, 3, 30, 15, 9, 45, 36, 12, 12]
dupItems = []
uniqItems = {}
for x in lst:
   if x not in uniqItems:
      uniqItems[x] = 1
   else:
      if uniqItems[x] == 1:
         dupItems.append(x)
      uniqItems[x] += 1
print(dupItems)
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #program #print #duplicates #list #integers #python
ADD COMMENT
Topic
Name
2+3 =