Python Get the Length of a Set
Get the Length of a Set
To determine how many items a set has, use the len()
method.
Example
Get the number of items in a set:
thisset = {"apple", "banana", "cherry"}
print(len(thisset))
Try it Yourself »
To determine how many items a set has, use the len()
method.
Get the number of items in a set:
thisset = {"apple", "banana", "cherry"}
print(len(thisset))
Try it Yourself »
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.