Skip to content
Advertisement

How do you eliminate items from nested lists

Given a list of ranked ballots and a list of candidates to eliminate, I need to return a new list of ranked ballots where all the candidates in the list of candidates to eliminate have been removed.

This is the code I’ve tried so far

JavaScript

My first doctest is failing, giving me this output instead:

JavaScript

Advertisement

Answer

This is the function required. It searches through the sublists:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement