Copying sets

As with the other built-in collections, set sports a copy() method which performs a shallow copy of the set (copying references but not objects):

>>> j = k.copy()
>>> j
{128, 81, 37, 54, 108, 12}

As we have already shown, the set() constructor may be used:

>>> m = set(j)
>>> m
{128, 81, 37, 54, 108, 12}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset