The error in the syntax of the provided code is: You cannot add a conditional statement after the else keyword.
The correct way to structure the code would be to use just else:
without any condition. The else
statement automatically handles the case where the if
condition is not met. Here’s the corrected version of the code:
def is_year(year):
if year % 4 == 0:
print('Year is divisible by 4')
else:
print('Year is not divisible by 4')