Does a function always need to return something?



In this exercise, the sample function syntax shows a return. Does a function always have to return a value?


NO, a function does not always have to have an explicit return statement. If the function doesn’t need to provide any results to the calling point, then the return is not needed. However, there will be a value of None which is implicitly returned by Python.


How do we know if the function needs to provide results to the calling point or not?


That is up to you as a programmer. You have to decide. There isn’t a fixed rule for this.

I am afraid you will just have to practice this by building software/programs.