Menu Close

Python Set copy() Method

Python set copy

In this tutorial we are going to learn all about Python set copy() method along with an example. copy function in python is used to create copy of the set.

In the previous tutorial, we have seen all about python set along with some examples.
I recommend, before going through this tutorial, please check out our previous python set tutorial.

Python set copy() method

copy function in Python is a set function that is used to create the copy of the set.

Syntax

The syntax of copy function in python is:-

set.copy()

Parameter

Python set copy function does not accepts any parameter.

Python set copy() exmaple

Here we will use set copy function to create the copy of the existing set.

Example:

my_set = { 1, 2, 3, 4, 5, 6, 7 }
print(my_set)
result = my_set.copy()
print(result)

Output:

{1, 2, 3, 4, 5, 6, 7}
{1, 2, 3, 4, 5, 6, 7}

Conclusion

In this tutorial, you have learned all about the copy function in python to create copy of the set. copy is a built-in set method that is only used with python set.

I hope this article will help you. If you like this article, please share it with your friends who want to learn Python programming.

Other set methods

For More Information:- Click Here

Previous Article
Next Article

Related Posts

Leave a Reply