Here we have a program which is calling the subtract function to calculate the difference between two numbers. The value from the subtract function is being stored in a variable called answer. Then answer is being displayed. Code is not executing as expected. Instead of seeing the answer, we are seeing the word "None."
Modify the code within the subtract function so the value for solution is returned when the function is called. When you are finished, the output should Desired Output.

# Define the subtraction function
def subtraction(minuend, subtrahend):
solution = minuend-subtrahend
print(minuend,"minus",subtrahend,"equals",solution)

# Call the subtraction function
subtraction(4, 10)

desired output:

10 minus 4 equals 6

Solved
Show answers

Ask an AI advisor a question