python programming to print duplicates from a list of integers Method 4: Using count() method

preview_player
Показать описание
# 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

# if the occurrence is more than
# one we add it to the output list
if n 1:

print(new)
Рекомендации по теме