Question

What error in this program needs to be fixed?

def sum(num1, num2)

return num1 + num2

print(sum(4, 5))

(1 point)
Responses

The first line needs a colon at the end.

The first line needs a colon at the end.

The second line needs a colon at the end.

The second line needs a colon at the end.

The final line needs a colon at the end.

The final line needs a colon at the end.

The final line needs a plus sign instead of a comma.

The final line needs a plus sign instead of a comma.
Skip to navigation

1 answer

The error in the program that needs to be fixed is:

The first line needs a colon at the end.

The correct definition of the function should have a colon (:) at the end of the def line. It should look like this:

def sum(num1, num2):
    return num1 + num2

This change will fix the syntax error in the function definition.