Counting Duplicates Integers in Python

count, duplicates, python

Solution

>>> j= [1,1,1,2,2,2]
>>> len(j) - len(set(j))
4

and btw, `j` is a list and not a string, although for the purpose of this exercise it doesn't really matter.

Problem

How do I find the total number of duplicates in a string? i.e., if it was `j= [1,1,1,2,2,2]` it would find `4` duplicates? I've only been able to find counting which shows how many times each individual number occurred.

Original source