Use python's len() method. The len() method returns the length or number of items of an object (character, list, tuple, etc.).
##len() method syntax: (Recommended learning: Python video tutorial)
len( s )
Parameters
s -- Object.Return value
Return the length of the object. ExampleThe following example shows how len() returns the number of elements of the set:
>>> a = set('abracadabra') >>> len(a) 5 >>>
Python Tutorial column to learn!
The above is the detailed content of How to get the number of set elements in python. For more information, please follow other related articles on the PHP Chinese website!