Skip to content
Advertisement

importing for loop output to another for loop

I am facing problem while importing the output of a for-loop to another for loop.

My python script

JavaScript

Actually facing problem in this line of code e = {d[0]: c, d[1]:[2.0,2.0]}, where value of c should be different but by this script i am getting repeated value.

JavaScript

Advertisement

Answer

Your problem is that you keep over writting the value if c which is why you only ever get the last value calculated in the next loop. You need to store the values in a list then read them back as needed.

Here I’ve created an empty list c = [] & then in the 3rd loop read out the values of c as indexed by the counter idx

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