#is this code correct

12 messages · Page 1 of 1 (latest)

winter cypress
#

'''def leap_year(year):
if year % 400 == 0:
return 'its leap year'
elif year % 100 == 0:
return 'its non leap year'
elif year % 4 == 0:
return 'its leap year'
else:
return 'its non leap year'
print(leap_year(2015))'''

lament void
#

What do the tests say when you run them?

fiery gale
whole spoke
#

What track? What do the tests say? @winter cypress

whole spoke
fiery gale
#

That's part of the condition of the task since the person is close to the solution. I just wanted to help.

whole spoke
#

Right. But we actively try to help by giving hints and examples, not final solutions.

chilly garnet
#

@winter cypress Let me help you a little bit.
When I took your code, copied it into the online editor and clicked "Run Tests", I got this test result:

9 tests failed

FAILED
Test 1
Leap > year not divisible by 4 in common year

Code Run
self.assertIs(leap_year(2015), False)

Test Failure
AssertionError: 'its non leap year' is not False

Do you understand this result?
Do you understand the message of the AssertionError ("'its non leap year' is not False")?

winter cypress
winter cypress
#

Tysm guys for your help