I have a this code:
sol = sp.solve(eqs, [p[0], p[1], p[2], p[3], lamda], dict=True)
p[0], p[1],... are variables for any Matrix p in sympy.
My question is: How can I use a cycle for instead to type each variable p[0], p[1],... etc.
I have a this code:
sol = sp.solve(eqs, [p[0], p[1], p[2], p[3], lamda], dict=True)
p[0], p[1],... are variables for any Matrix p in sympy.
My question is: How can I use a cycle for instead to type each variable p[0], p[1],... etc.
If you have a range of values (0-3 in your example) you can use the slice notation and * to unpack the values:
sol = sp.solve(eqs, [*p[0:4], lamda], dict=True)
Not a for loop, but avoids typing out a lot of values.