Python Practice › Set Programs › Program 23

Clear a set

EasySet Programs · 23 of 48

Write a Python program to remove all elements from a set.

Advertisement
Input
{1, 2, 3}
Output
set()

Approach

  1. clear().

Solution

Python
s = {1, 2, 3}s.clear()print(s)
Output
set()

Learn the concept

New to this topic? Read the lesson, then come back.

More set programs

← All 48 Set Programs

Leave a Comment