To answer the question in the title: Use len() to get the size of a set.
Semantically that is a bit weird, as a set is an unordered collection, and the length analogy kind of breaks down (we are actually measuring cardinality), but in the spirit of Python using len to get the size of all kinds of collections is easy to remember and it is quite obvious what the statement means.
Videos
A set is a datastructure for:
constructing and manipulating unordered collections of unique elements.
These collections have to be hashable as well. But we are lucky: strings and characters are hashable.
The point is that if we construct a set form set(['1','4','1','5','2']), it will thus construct a collection of unique elements. So adding '1' twice here, does not makes any difference, the result is set(['1', '4', '5', '2']) (or more conveniently written {'1', '4', '5', '2'}). With len(..) we obtain the size of a collection. So the size of that set is the number of unique characters of the input.
So if we write len(set(some_string)) we will first turn a string into a set. This is possible since a string is an iterable of the characters. So Python sees a string as an ordered collection of characters. 'abc', is a collection of 'a', 'b', and 'c'. So every digit is seen as an element and added to the set.
But adding the same digit a second time, has no effect. So that means that we end up with a set where every digit is added once. By then calculating the len(..) we obtain the number of unique digits. We can then compare that number with a given number.
In Python, every input is a string, which can be converted to a list of characters. When a list is converted to a set, it keeps the unique elements.
So, when your code turns the string of digits into a set, it only keeps the unique digits. Then, when you find the length, it returns the number of unique digits.