Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Add() 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

bookAdd() Method

You can also add elements to a set. To do this, there's a specific add() method. It's important to note that with this method, you can add only one element at a time. So, if you want to add 4 elements, for example, you'll need to use this method 4 times. Let's check out an example.

123456789
set_1 = set() print(set_1) # Adding elements set_1.add('one') set_1.add('two') set_1.add('three') set_1.add('four') print(set_1)
copy

Task

Here's your set:

Now, add these numbers to the set:
22, 24, 26, 28

Make sure to use the add() method.

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 2
toggle bottom row

bookAdd() Method

You can also add elements to a set. To do this, there's a specific add() method. It's important to note that with this method, you can add only one element at a time. So, if you want to add 4 elements, for example, you'll need to use this method 4 times. Let's check out an example.

123456789
set_1 = set() print(set_1) # Adding elements set_1.add('one') set_1.add('two') set_1.add('three') set_1.add('four') print(set_1)
copy

Task

Here's your set:

Now, add these numbers to the set:
22, 24, 26, 28

Make sure to use the add() method.

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 2
toggle bottom row

bookAdd() Method

You can also add elements to a set. To do this, there's a specific add() method. It's important to note that with this method, you can add only one element at a time. So, if you want to add 4 elements, for example, you'll need to use this method 4 times. Let's check out an example.

123456789
set_1 = set() print(set_1) # Adding elements set_1.add('one') set_1.add('two') set_1.add('three') set_1.add('four') print(set_1)
copy

Task

Here's your set:

Now, add these numbers to the set:
22, 24, 26, 28

Make sure to use the add() method.

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!

You can also add elements to a set. To do this, there's a specific add() method. It's important to note that with this method, you can add only one element at a time. So, if you want to add 4 elements, for example, you'll need to use this method 4 times. Let's check out an example.

123456789
set_1 = set() print(set_1) # Adding elements set_1.add('one') set_1.add('two') set_1.add('three') set_1.add('four') print(set_1)
copy

Task

Here's your set:

Now, add these numbers to the set:
22, 24, 26, 28

Make sure to use the add() method.

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