Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find duplicate numbers in list in python

l=[1,2,3,4,5,2,3,4,7,9,5]
l1=[]
for i in l:
    if i not in l1:
        l1.append(i)
    else:
        print(i,end=' ')
Comment

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)
Comment

Python | Program to print duplicates from a list of integers

# program to print duplicate numbers in a given list
# provided input
list = [1, 2, 1, 2, 3, 4, 5, 1, 1, 2, 5, 6, 7, 8, 9, 9]
 
new = []  # defining output list
 
# condition for reviewing every
# element of given input list
for a in list:
 
     # checking the occurrence of elements
    n = list.count(a)
 
    # if the occurrence is more than
    # one we add it to the output list
    if n > 1:
 
        if new.count(a) == 0:  # condition to check
 
            new.append(a)
 
print(new)
 
Comment

PREVIOUS NEXT
Code Example
Python :: python asctime 
Python :: pandas read_csv dtype datetime 
Python :: flask subdomains 
Python :: install python altair 
Python :: Image Watermarking in python 
Python :: split word python 
Python :: drop na dataframe 
Python :: pdf to csv 
Python :: print dictionary of list 
Python :: compare two dictionaries in python 
Python :: calculate percentile pandas dataframe 
Python :: newsapi in python 
Python :: how to define the name of your tkinter window 
Python :: how to create enter pressed for qlineedit in pyqt5 
Python :: pandas dataframe add column from another column 
Python :: norm in python 
Python :: unittest skip 
Python :: how to import your own function python 
Python :: input numpy array 
Python :: iterate over dictionary django 
Python :: filter one dataframe by another 
Python :: install play sound python terminal 
Python :: python django model range validation 
Python :: python for loop get iteration number 
Python :: re.compile example 
Python :: how to install python dill 
Python :: python list of dictionary unique 
Python :: # extract an email ID from the text using regex 
Python :: python draw circle matplotlib 
Python :: python rgb to hex 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =