Why do I get the syntax error SyntaxError invalid syntax in a line with perfectly valid syntax

0 votes

I have this code:

def Psat(self, T):
    pop= self.getPborder(T)
    boolean=int(pop[0])
   
    P1=pop[1]
    P2=pop[2]
    if boolean:
        Pmin = float(min([P1, P2]))
        Pmax = float(max([P1, P2]))
        Tr=T/self.typeMolecule.Tc
        w=0.5*(1+scipy.tanh((10**5)*(Tr-0.6)))
        fi1=0.5*(1-scipy.tanh(8*((Tr**0.4)-1)))
        fi2=0.460*scipy.sqrt(1-(Tr-0.566)**2/(0.434**2)+0.494

        guess = Pmin+(Pmax-Pmin)*((1-w**2)*fi1+(w**2)*fi2)   # error here
    
        solution = scipy.optimize.newton(funcPsat,guess, args=(T,self))

On the marked line of code, guess = Pmin+(Pmax-Pmin)*((1-w**2)*fi1+(w**2)*fi2), I get an error message: SyntaxError: invalid syntax.

Pmin, Pmax, w, fi1 and fi2 have all been assigned at this point, so why is there an error?

When I remove that line from the code, the same error appears at the next line of code, again for no apparent reason.

Jan 6, 2023 in Python by erzan
• 630 points

edited 4 days ago 7 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP