I'm trying to understand how to properly define a function using the def().
I have come across question about using print() and return under def.
Now here are the two scripts I wrote:
def study_time(math,english,literature,chemistry):
total = math + english + literature + chemistry
short = 10 - total
if total >= 10:
print ("You have completed today's study goal!")
else:
print ("Keep going! You are still " + str(short) + " hours short!")
result = study_time(2,3,1,4)
print (result)
For this one I used print(), and when I called the function it returned two values: 1. The value I want it to present, and 2. None
def study_time(math,english,literature,chemistry):
total = math + english + literature + chemistry
short = 10 - total
if total >= 10:
return ("You have completed today's study goal!")
else:
return ("Keep going! You are still " + str(short) + " hours short!")
result = study_time(2,3,1,4)
print (result)
For this other one I used return, and the function returned only 1 value without the None
I'm just very curious what might explain the difference