Question : Python: how to write this expression

Hi experts,

In the attached code, "oper" can be anything like '<', '>=', '==', etc. "exp_1" and  "exp_2" are all integer numbers.

I got an error for the 2nd line. The error was "SyntaxError: invalid syntax". Anybody knows how to fix it?

Thanks a lot.
Code Snippet:
1:
2:
3:
4:
def check_condition(self, exp_1, oper, exp_2)
      cond = ("%s  %s   %s") % (exp_1   oper   exp_2)
      if (cond):
            print "condition is true"
Open in New Window Select All

Answer : Python: how to write this expression

No comma's between the values in the list of values to be formatted...
1:
cond = ("%s  %s   %s") % (exp_1, oper, exp_2)
Open in New Window Select All
Random Solutions  
 
programming4us programming4us