Module 6
return vs print
Two different things.
Output vs result
print shows information on the screen. return gives a value back to the code that called the function. They are different.
Python
def double_print(x):
print(x * 2)
def double_return(x):
return x * 2
double_print(5)
result = double_return(5)
print(result)→ 10
10
Try it
Use print when you want to show something to the user. Use return when you want to compute a value that other code will use.