Python Tutorial Python Advanced Python Resources Python Libraries
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

Python - Set copy() Method



The Python set copy() method is used to copy the entire set into a new set.

Syntax

set.copy()

Parameters

No parameter is required.

Return Value

Returns a copy of the specified set.

Example:

In the example below, the set called MySet is copied entirely into a new set called NewSet. To perform this operation the copy() method is used.

MySet = {'Red', 'Blue', 'Green'}
NewSet = MySet.copy()
print(NewSet)

The output of the above code will be:

{'Blue', 'Red', 'Green'}

❮ PPython Set Methods

5