Course Content
Python Data Structures
Python Data Structures
Add() 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.
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)
Task
Here's your set:
Now, add these numbers to the set:22
, 24
, 26
, 28
Make sure to use the add()
method.
Thanks for your feedback!
Add() 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.
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)
Task
Here's your set:
Now, add these numbers to the set:22
, 24
, 26
, 28
Make sure to use the add()
method.
Thanks for your feedback!
Add() 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.
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)
Task
Here's your set:
Now, add these numbers to the set:22
, 24
, 26
, 28
Make sure to use the add()
method.
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.
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)
Task
Here's your set:
Now, add these numbers to the set:22
, 24
, 26
, 28
Make sure to use the add()
method.