Python List - len function

The len function returns the number of elements present in a python set which is also known as the cardinality of a set.

Set Updated 16 Sep 2016 1 min read

Method Name: len(set_in)

Method Overview

The len() method returns the number of elements present in the set.
The number of elements present in the set is called as the cardinality of the set.

Parameters

set_in: The set for which the length needs to be found.

Return Value

The number of elements present in the set otherwise known as cardinality of a set.

python
>>> EMWaves = {"Radio waves","Micro waves","Infrared waves","Visible light","Ultraviolet waves","X-ray","Gamma rays"}

>>> len(EMWaves)

7