Support Forums

Full Version: Need some help with a simple calcfunc.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, im new to the program and i'm trying to create a function can solves a string input.
For example, user input: "1-5".
My program:
PHP Code:
def subtraction(n):
    if 
n.find('-')>0:
        
an.split('-'1)
        return 
subtraction(b)-subtraction(a)
    else:
        return 
float(n
will return as wanted -4, however if i type for example:
"1-5-1"
my program would return -3.
my problem is that the last expression is calculated first, so from "1-5-1" i would get 1-(5-1) = -3, how do i fix this to make it correct?