Identify the error in the syntax of the following code:

def is_year(year):
if year % 4 == 0:
print('Year is divisible by 4')
else year % 4 != 0:
print('Year is not divisible by 4')
(1 point)
Responses

The print statements shall be ended with a semi-colon.
The print statements shall be ended with a semi-colon.

There

1 answer

The error in the syntax of the code is in the else statement. The correct syntax does not require a condition after else. Here’s the corrected version:

def is_year(year):
    if year % 4 == 0:
        print('Year is divisible by 4') 
    else:
        print('Year is not divisible by 4')

So the specific error is that the line else year % 4 != 0: is incorrect; it should simply be else: without the condition.

Similar Questions
    1. answers icon 1 answer
  1. Identify the error in the syntax of the following code:def is_year(year): if year % 4 == 0: print('Year is divisible by 4') else
    1. answers icon 1 answer
  2. Identify the error in the syntax of the following code:def is_year(year): if year % 4 == 0: print('Year is divisible by 4') else
    1. answers icon 1 answer
  3. Identify the error in the syntax of the following code:def is_year(year): if year % 4 == 0: print('Year is divisible by 4') else
    1. answers icon 1 answer
more similar questions