Problem when iterating through lists of different size and levels in python

I have two lists of diferent sizes and diferent amount of levels.
I need to iterate both lists but i keep getting error messages

L1 has level 1 and 2
L2 has level 1, 2 and 3

i need to create a list that returns for me the value of L2 at level 2 that is the first one bigger than the value of L1


This is the code
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
L1 = [1.69, 18.75]
L2 = [[17.5, 24, 32, 41, 57, 76, 101, 125, 151, 192, 232, 269, 309, 353, 415, 477, 571, 656, 758, 881, 1012],[17.5, 24, 32, 41, 57, 76, 101, 125, 151, 192, 232, 269, 309, 353, 415, 477, 571, 656, 758, 881, 1012]]
res =

for i, j in L1,L2:
	for num in j:
		if i <= num:
			res.append(num)
			break
	

#Assign your output to the OUT variable.
OUT = res

This is the error message:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 10, in
TypeError: iteration over non-sequence of type float

Thank you all in advance for your help!

Hi,

Maybe with function zip :

L1 = [1.69, 18.75]
L2 = [[17.5, 24, 32, 41, 57, 76, 101, 125, 151, 192, 232, 269, 309, 353, 415, 477, 571, 656, 758, 881, 1012],[17.5, 24, 32, 41, 57, 76, 101, 125, 151, 192, 232, 269, 309, 353, 415, 477, 571, 656, 758, 881, 1012]]
res = []

for i, j in zip(L1,L2):
	for num in j:
		if i <= num:
			res.append(num)
			break
#Assign your output to the OUT variable.
OUT = res

The result seems correct.
result

It solved the problem.
Thank you.
But how exactly does the zip function works?

You’re welcome.

The python documentation will explain you better than me how it works.
https://www.programiz.com/python-programming/methods/built-in/zip

I use very often the zip() function in the customs nodes of my package.