[Solved] How can I define functions in a for loop?


① You are nesting lists although you just want a flat list (of functions). See the answer of @BartoszKP on that.

② You want to create functions based on local variables. You can do this using lambdas, as @Harsh is proposing, or you can do it using defaulted variables:

def F_analytic(k, m, c, f=f):  # notice the f=f here!
    F_t = k*m*c*f 
    return F_t

③ You should consider whether having a list of functions really is what you want (as @Wooble already pointed out).

1

solved How can I define functions in a for loop?