Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Clear() Method | Set
Python Data Structures
course content

Course Content

Python Data Structures

Python Data Structures

1. List
2. Dictionary
3. Tuple
4. Set
5. For deleting

bookClear() Method

Just like in other data structures, the clear() method completely wipes out all the elements. Let's dive into the example below.

12345
set_1 = {10, 'Joe', 'cat', True, 134} print(set_1) set_1.clear() print(set_1)
copy

Task

You've got the set:

Your task is to erase all the items from this set.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 6
toggle bottom row

bookClear() Method

Just like in other data structures, the clear() method completely wipes out all the elements. Let's dive into the example below.

12345
set_1 = {10, 'Joe', 'cat', True, 134} print(set_1) set_1.clear() print(set_1)
copy

Task

You've got the set:

Your task is to erase all the items from this set.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 6
toggle bottom row

bookClear() Method

Just like in other data structures, the clear() method completely wipes out all the elements. Let's dive into the example below.

12345
set_1 = {10, 'Joe', 'cat', True, 134} print(set_1) set_1.clear() print(set_1)
copy

Task

You've got the set:

Your task is to erase all the items from this set.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Just like in other data structures, the clear() method completely wipes out all the elements. Let's dive into the example below.

12345
set_1 = {10, 'Joe', 'cat', True, 134} print(set_1) set_1.clear() print(set_1)
copy

Task

You've got the set:

Your task is to erase all the items from this set.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 4. Chapter 6
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt