mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-26 20:34:32 +03:00
Clarification about sets
I indicate that a set doesn't contain duplicate elements and add a little example
This commit is contained in:
parent
76bb8b21f6
commit
04de3a348a
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user