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.
Python set not changing the length of new list? - Unix & Linux Stack Exchange
How to set a max length for a python list/set? - Stack Overflow
How to create a fixed-length list that accepts its size when declared?
Do you use black with its default line length of 88?
Videos
You don't and do not need to.
Python lists grow and shrink dynamically as needed to fit their contents. Sets are implemented as a hash table, and like Python dictionaries grow and shrink dynamically as needed to fit their contents.
Perhaps you were looking for collections.deque (which takes a maxlen parameter) or something using a heapq (using heapq.heappushpop() when you have reached the maximum) instead?
Once you have your list, lst, you can
if len(lst)>10:
lst = lst[:10]
If size more than 10 elements, you truncate to first ten elements.