Complete newbie to python, only really looked at it this morning. My question is when defining a function how can I set the "return(variable)" statement as a string. I assumed the below would be the correct method however the syntax is incorrect, struggling to find resources online for this particular way of converting the data type. The result is forming as follows:
"The result is:
By converting it to a string it should form: "The result is: 286"
Here is what I thought would work:
def fnc2(a,b,c): total=(a+b)*c print("the result is: ") + str(return(total));
A few things:
- Python spacing matters, so don't forget to indent!
- Check your
One form of correct syntax would be:
def fnc2(a, b, c): total = (a + b) * c print("The result is: " + str(total))