1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-17 20:11:57 +02:00

Merge pull request #653 from xksteven/master

[python 3/en] fixed error in sets
This commit is contained in:
Adam Bard
2014-06-16 22:10:17 +02:00

View File

@@ -238,7 +238,10 @@ empty_set = set()
# Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry. # Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry.
some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4} some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4}
# Add more items to a set #Can set new variables to a set
filled_set = some_set
# Add one more item to the set
filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5} filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5}
# Do set intersection with & # Do set intersection with &