+ 1
Why my code doesn't work in the code Playground exercise (Python)
My function doesn't return anything even when I return a variable with the result: #taking the weight as input weight = int(input()) #complete the function def shipping_cost(weight): cost = weight * 5 return cost #function call shipping_cost(weight)
3 ответов
+ 7
It does return something, you're just not printing anything. Can either store the information returned and then print like this:
result = shipping_cost(weight)
print(result)
Or just put thr function call in a print statement:
print(shipping_cost(weight))
+ 3
You need to use print on your function call like this:
print(shipping_cost(weight))
+ 2
Oh thanks guys, I didn't see I had to use the shipping_cost function as an argument of the print function.
Now it makes sense, thanks a lot guys!👍🏻