So I'm very new to Python, following '100 days of code' on udemy. So far I've been able to follow along fine. I'm starting to struggle now when I've gotten to functions and returns though.
def is_leap(year):
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print("Leap year")
else:
print("Not leap")
else:
print("Leap year")
else:
return ("Not leap")
is_leap(int(input("Provide a year.")))
This works as expected, printing out leap/not leap.
When instead changing out the prints to returns, I do not manage to get an output.
def is_leap(year):
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
else:
return True
else:
return False
is_leap(int(input("Provide a year.")))
My question is basically two folded. Should the latter code not return True or false as an output? And if not, how would I go about doing that?