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 ie the "truthy" list
If the result of the callback function is False the element should go into the second list ie the "falsy" list
When it's finished, partition should return both lists inside of one larger list, like so:
truthylistfalsylist
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
