Question: Write a function called partition. This function accepts a list and a callback function that returns True or False ( which is provided in the

Write a function called partition. This function accepts a list and a callback function that returns True or False (which is provided in the attached file).
The function should iterate over each element in the list and invoke the callback function at each iteration.
If the result of the callback function is True , the element should go into the first list (i.e. the "truthy" list).
If the result of the callback function is False , the element should go into the second list (i.e. the "falsy" list).
When it's finished, partition should return both lists inside of one larger list, like so:
[[truthy_list],[falsy_list]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!