(Aug-09-2020, 05:13 PM)ndc85430 Wrote: map
takes a function as its first argument and applies it to each item of the iterable passed as its second argument. In the two examples, I pass in two different functions: one that doubles the argument that I use with the list of ints and one that turns its argument to uppercase, which I use with the list of strings.
Thanks, it's useful to recall this as I will do a lot of list calculation. I'll see how that can simplify my clumsy codes but currently it would be great if I have a way to define multiple functions within the same def process.
(Aug-09-2020, 05:18 PM)Yoriz Wrote: I'm not quite sure what you are after but maybe your better of with a class ?
Seems to be more like a programmer's work but I would still need to assign something to an output each time before getting the ratio and index. I will use the function a lot so it would add up the work. Besides that also means I cannot maintain the structure of line 5 of a higher function I showed earlier, since the ratio still cannot be just called up as a function.
def maxexternalratio(a, b, yr): Etemp = [] for i in range(len(a)): for j in range(len(a)): Etemp.append(external(a, b, a[i], b[j], yr)['ratio']) return max(Etemp)If so I think I'd rather define two functions separately with nearly identical codes although that would be clumsy and obviously amateur.