Skip to content
Advertisement

Divide consecutive element in a nested list by consecutive elements in another list

I have a nested list that looks something like this:

JavaScript

and a flat list that looks something like this:

JavaScript

How do I divided each consecutive element in list1 by each consecutive element in list2 (e.g. 42/2, 432/4, 34/2, 242/6) to get an output like this:

JavaScript

I have tried doing this:

JavaScript

but since list1 is a nested list there was some error in the code.

Advertisement

Answer

Here is a possible solution:

JavaScript

This is the output:

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