Python Language Set: Difference between revisions
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
=Overview= | =Overview= | ||
=Initialization= | =Initialization= | ||
Literal initialization: | |||
<syntaxhighlight lang='py'> | |||
s = {1, 2, 3} | |||
</syntaxhighlight> | |||
Set from a tuple: | Set from a tuple: | ||
<syntaxhighlight lang='py'> | <syntaxhighlight lang='py'> |
Revision as of 19:00, 28 August 2022
Internal
TODO
- TO PROCESS PyOOP "Sets"
Overview
Initialization
Literal initialization:
s = {1, 2, 3}
Set from a tuple:
s = set((1, 2, 3))
Set from a list:
s = set([1, 2, 3])
Set from a string:
s = set('ABC')
print(s) # {'C', 'B', 'A'}
Shallow Copy
s = set()
s.add('a')
s2 = s.copy()