1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-13 02:04:23 +02:00

Merge pull request #3180 from robertofd1995/patch-1

Python3 Clarification about sets
This commit is contained in:
Adam Bard
2018-08-23 22:26:20 -07:00
committed by GitHub

View File

@@ -7,6 +7,7 @@ contributors:
- ["Zachary Ferguson", "http://github.com/zfergus2"]
- ["evuez", "http://github.com/evuez"]
- ["Rommel Martinez", "https://ebzzry.io"]
- ["Roberto Fernandez Diaz", "https://github.com/robertofd1995"]
filename: learnpython3.py
---
@@ -352,6 +353,8 @@ valid_set = {(1,), 1}
# Add one more item to the set
filled_set = some_set
filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5}
# Sets do not have duplicate elements
filled_set.add(5) # it remains as before {1, 2, 3, 4, 5}
# Do set intersection with &
other_set = {3, 4, 5, 6}