Question: In the module question3.py, write a function select(a, b) that takes a list a of any types and a second list b of boolean (True/False)

In the module question3.py, write a function select(a, b) that takes a list a of any types and a second list b of boolean (True/False) values as its arguments and returns a list made up by selecting elements from a where the corresponding value in b is equal to True. The list a must be shorter than the list b, otherwise a valueError is raised. Examples: t = select([1], [True]) returns the list [1] t = select([1], [False]) returns the empty list [] t = select([0, 2], [True, False]) returns the list [0] t = select([0, 2], [False, True]) returns the list [2] t = select(['a', 'b'], [True, True]) returns the list ['a', 'b'] t = select([0, 2, -3, 9, 14], [False, False, True, False, True]) returns the list (-3, 14] t = select([-3, 8, 7], [False]) raises a ValueError
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
