Maryan Tuzyak1,487 Points
converting the arguments into floats
i have tried converting the top arguments into floats but not sure if doing it properly i'm assuming converting arguments to floats before adding them ,tried float() to total and add keeps telling me error in line 1
def add float((n1,n2)): return(n1+n2) total = add(2,8) print(total)
Kent Åsvang18,813 Points
You can't convert the argument-list - instead you should consider to convert the numbers inside your function. This is how I would do it:
def add(a, b): return float(a+b) # but you could also do something like this for clarity: def add(a, b): a = float(a) b = float(b) sum = a + b return sum
Hope this helped.