Hello, new here and a beginner with using Python.
So my code looked like this:
def cube(num): num*num*num print(cube(4))
So this doesn’t work. So then I was instructed to do this (add return):
def cube(num): return num*num*num print(cube(4))
So I have two questions:
- Why didn’t the code work previously? Why did I have to add return?
- What exactly does return do? When is it useful irl?
If someone only knows the answer to 1., that’s fine too. Thanks in advance!