Return Values vs Print

Python

Return vs Print

Return vs Print

The Difference

PRINT: Shows output, returns nothing

def add_print(a, b): print(a + b)

RETURN: Gives back a value to use

def add_return(a, b): return a + b

Using them

result1 = add_print(5, 3) # Prints 8, result1 is None result2 = add_return(5, 3) # result2 is 8

Key insight: Return when you need to use the result later!

Your Task

Fix the calculate_tax function below. It currently prints the result but should return it so we can use it in further calculations.

Code Editor
Loading PYTHON engine...
Loading...
Loading Python engine...

Run your code to see output