New list with largest value among sublists ; Python, Lists

I am trying to get biggest value among sub-lists and produce one list
not sure why it does work as expected

Code.txt (455 Bytes)

@Michal_Dengusiak You need answer in Python or OOTB nodes?

Yes I need python as I need better understand codes

your code has a couple of issues, you set the value of Xcurrent and you’re appending a value to pairs list at each iteration .
Try this:

maxlist = []
for i in IN[0]:
	max = i[0]
	for k in i:
		if k>max:
			max = k

OUT = maxlist

also, python has a built in max method :


Hi it is not max value form each sub-lists… we take each element among sublists and then find largest…all sublist got same lenght

aslo we have some empty cells in lists… so will be no value in some as well

the function works with nulls as well :

we take each element among sublists and then find largest
i’m not sure I got this part

here is example:
[ ] [2]
[3] [ ]
[ ] [5]
[7] [2]

result should be


@Michal_Dengusiak - Not sure if this is what you are looking for, but we have a node that returns the maximum item and will replicate through sublists…works with nulls as well…

Additionally, your initial list looks like it has empty values which will likely be interpreted as strings. You may want to replace those as null values.

Hope that helps.

capture.dyn (5.2 KB)

1 Like