Syntax Error in a mathematical operation inside a for loop

I'm having troubles with the following code:

`

  for i in range(len(masa)):
    
    denom =np.pi*radio[i]*densi[i]*c_p[i]*(alpha_list[i] *altura_hp[i])**2
    termino_1 = (lum[i]/denom)
    termino_2 = (temp[i]/(G*masa[i])**(1.0/2.0)
    delnabl_i = (termino_1 * termino_2)**(2.0/3.0)

`

all the variables are well defined and tested. Anyways I get

 File "<ipython-input-660-d2be9b4c4439>", line 25
    delnabl_i = (termino_1 * termino_2)**(2.0/3.0)
            ^
SyntaxError: invalid syntax

What's happening here? I guess there's an obvious mistake I'm not seeing

1 answer

  • answered 2020-10-16 04:32 Divyessh

    for i in range(len(masa)):
        
        denom =np.pi*radio[i]*densi[i]*c_p[i]*(alpha_list[i] *altura_hp[i])**2
        termino_1 = (lum[i]/denom)
        termino_2 = (temp[i]/(G*masa[i])**(1.0/2.0))
        exec(f'delnabl_{i}) = (termino_1 * termino_2)**(2.0/3.0)')
    

    Use this