Google News
logo
Python Program to Get the length of a set
You can get the length of a set in Python using the `len()` function. Here is an example :
Program :
my_set = {1, 2, 3, 4, 5}
print(len(my_set))
Output :
5
In this example, we create a set `my_set` with 5 elements. Then, we use the `len()` function to get the length of the set and print it to the console.

The output will be `5`, which is the number of elements in the set.