Identify syntax errors from the following python constructions and rewrite the connected one. (there can be more than one in each statement.
If answer="Y"
total=total+1
else
print("error")

Respuesta :

Answer:

The syntax errors are:

(1) If answer = "Y"

(2) else

Explanation:

Given

The above code snippet

Required

The syntax error

The first syntax error is: If answer = "Y"

When making equality comparison, the == sign is used not =

The "If" must be in lower case

And, colon (:) is appended at the end of the condition.

So, the correction will be:

if answer == "Y":

The second syntax error is: else

Colon (:) must be appended at the end of the condition.

So, the correction is:

else:

The correct code is:

if answer == "Y":

    total = total + 1

else:

    print("error")