125k views
0 votes
Write a method in bag such that if b1 and b2 were bags then b1+b2 gives a new bag representing the union of the two bags.

1 Answer

6 votes

The method to represent that if b1 and b2 were bags then b1+ b2 gives a bag representing the union of the two bags can be explained as follows:

a. input (b1)

a. input (b2)

b= Bag ( )

b.input ()

Print (b1+b2)

User Buga
by
7.8k points