Skip to content

Commit

Permalink
update commit
Browse files Browse the repository at this point in the history
  • Loading branch information
akrish4 authored Sep 21, 2020
1 parent c74f116 commit 887a98a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Ananthakrishnan_Python_sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,26 @@
print(carset)
##### output :
NameError: name 'carset' is not defined

## Join Two Sets
- There are several ways to join two or more sets in Python.

- You can use the union() method that returns a new set containing all items from both sets, or the update() method that inserts all the items from one set into another:
##### Example : by union()
set1 = {"Swift", "Brezza" , "Baleno"}
set2 = {1, 2, 3}

set3 = set1.union(set2)
print(set3)
##### output :
{1, 2, 3, 'Baleno', 'Brezza', 'Swift'}
##### Example : by update()
set1 = {"Swift", "Brezza" , "Baleno"}
set2 = {1, 2, 3}

set1.update(set2)
print(set1)
##### output :
{1, 2, 3, 'Baleno', 'Brezza', 'Swift'}
## Set Methods
- Python has a set of built-in methods that you can use on sets.

Expand Down

0 comments on commit 887a98a

Please sign in to comment.