+ 1
Why the return here is an error?
def is_leap(year): if year % 4 == 0 and year %100 !=0 or year % 400 == 0: leap = True else: leap = False return leap year = int(input()) print(is_leap(year))
4 Answers
+ 5
Because return isn't inside function
example
def function:
if
else
return
+ 5
Because return statement is Out of is_leap() scope
Here is the correct code
def is_leap(year):
if year % 4 == 0 and year %100 !=0 or year % 400 == 0:
leap = True
else:
leap = False
return leap
year = int(input())
print(is_leap(year))
0
Check indention properly