[Solved] Count of different numbers in one long number [closed]


You can do that as:

print len(set(str(s)))

The str() casts the int as a string
The set() takes the unique elements of the string and creates a set of it
The len() returns the length of the set

Examples

>>> print len(set(str(s)))
5

s = 1324082304

>>> print len(set(str(s)))
6

10

solved Count of different numbers in one long number [closed]