Finding the Length of a Set

Tags: len, Set

Write a Python program to find the length of a set. The function should return the length of the set.

Example 1:

Input: {1, 2, 3, 4, 5} 
Output: 5

Example 2:

Input: {"apple", "banana", "cherry"}
Output: 3

Use the built-in function len() to find the length of a set.

def find_length(set1):
    return len(set1)

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!