Help me, please!


Hi everyone,
I have a problem about my exercise when i try to practice "function" in Python. Below is my code:

def cube(number):
print number ** 3
return number
def by_three(number):
print cube(number)

And the result which printed in the console is:

I don't understand why number "3" is displayed here. Please explain about this for me. Thanks a lot!


print cube(3)

Inside by_three function you call the cube function with 3 (you called by_three(3))as an argument.and inside cube function you return the number

return number

so number is 3 (you called cube(3))

you can see the number 2 if you call cube(2) with print statement

print cube(2)


I found my problem after your explanation. Thank you so much!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.