how to find duplicate numbers in list in python

some_list=['a','b','c','b','d','m','n','n']

 my_list=sorted(some_list)
 
duplicates=[]
for i in my_list:
     if my_list.count(i)>1:
         if i not in duplicates:
             duplicates.append(i)
 
print(duplicates)

Here is what the above code is Doing:
1. We create a list called my_list and sort it.
2. We create an empty list called duplicates.
3. We iterate through my_list.
4. We check if the number of occurrences of the current element of my_list is greater than 1.
5. If it is, we check if it’s already in duplicates.
6. If it isn’t, we append it to duplicates.
7. We print duplicates.