0

Basic Functions Question

Really basic question - think I'm having a mental block - what do I need to do to make this work? def my_sum(a,b) Return (sum(a,b)) print my_sum my_sum(5,6) Hopefully bits obvious what I am trying to do. I can do it like this: def my_sum(a,b) Return a+b Print (my_sum(4,5)) I just wanted it all rolled up into an easier chunk. Thanks!

3/31/2020 12:46:56 PM

Andrew Chadwick

3 Answers

New Answer

0

def my_sum(a,b): return a+b print(my_sum(5,7)) #Return syntax error. Use small r in return #also small in print()

0

Yeh sorry ignore the capital letters - it was just my phone. I still can't get it to work with the print in the function rather than out of it

0

If you want to print in function, write before return statement. If return statement executed, then control comes back to called function. statement after return call, never executed... def my_sum(a,b): print(a+b) return my_sum(5,7)