Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


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 below example, 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