Python - Set copy() Method


Advertisements

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

Syntax


set.copy()

Parameters

No parameter is required.

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)

Output

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

Sets Methods




Advertisements