+ 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))

10th Dec 2021, 1:52 PM
Nisha
4 Answers
+ 5
Because return isn't inside function example def function: if else return
10th Dec 2021, 1:55 PM
Sardorbek Karimov
Sardorbek  Karimov - avatar
+ 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))
10th Dec 2021, 1:56 PM
Pariket Thakur
Pariket Thakur - avatar
0
Check indention properly
10th Dec 2021, 7:52 PM
elly paul
elly paul - avatar