forked from kumaya/python-programs
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetOperation.py
More file actions
Latest commit
16 lines (11 loc) · 485 Bytes
/
Copy pathsetOperation.py
File metadata and controls
16 lines (11 loc) · 485 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# set operation in list
l1= [1,2,3,4,5]
l2= [3,4,5,6,7]
# Return an array containing all elements of both array
printlist(set(l1).union(l2))
# Return an array containing common elements of both array
printlist(set(l1).intersection(l2))
# Return an array containing all elements of first array which are not in second
printlist(set(l1).difference(l2))
# Return an array containing unique elements of both array
printlist(set(l2).difference(l1).union(set(l1).difference(l2)))