I was having trouble on the Sal’s shipping project and I looked at some community forums for help and got the correct code and now I’m trying to find what I did wrong. This is what I put:
return cost
print(ground_shipping(8.4))
And this is what I get:
Output:
File “shipping.py”, line 8
return cost
^
SyntaxError: ‘return’ outside function
Can someone help me with this and say what I’m doin wrong?
Your function is named cost_ground so it is confusing why the same name is given to the internal variable. I would change that, for starters.
Also, == is not assignment, but comparison.
cost = weight * 1.50
If the printing is being done inside the function, then there is no return value to use elsewhere after the function call. But if the print statement is as we see it, and it is outside of the function, then it appears to be expecting a return value to print.
return cost + 20
Note that since the base amount is the same for all four cases, we can tack it on at the return stage.