Does a function always need to return something?


#1

Question

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

Answer

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.


#2

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


#3

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.