Clearing a Set

Tags: clear, Set

Write a Python program to clear a set. The function should return an empty set.

Example 1:

Input: {1, 2, 3, 4, 5} 
Output: set()

Example 2:

Input: {"apple", "banana", "cherry"} 
Output: set()

Use the clear() method in Python to clear the contents of a set.

def clear_set(set1):
    return set1

© Let’s Data Science


Unlock AI & Data Science treasures. Log in!