Python: set.union()
, issuperset()
Using set.union()
to combine subsets for issuperset()
evaluation
Input the following lines at the Bash CLI:
python chk_superset.py
1 2 3 4 5 6 7 8 9 10 11 12 23 45 84 78
1 2 3 4 5
100 11 12
- superset values
- 1st subset
- 2nd subset
Returns False
, since none of the values in the 2nd subset are listed in the superset:
False
In the Python 3 interpreter CLI:
>>> A = set( map(str, input().split()) )
1 2 3 4 5 6 7 8 9 10 11 12 23 45 84 78
>>> b = set().union( input().split(), input().split() )
1 2 3 4 5
100 11 12
>>> print(b)
{'3', '5', '11', '4', '100', '12', '1', '2'}
>>> print(A.issuperset(b))
False