0

Can you give your time to improve and suggest on the following code?

Here's my code! https://code.sololearn.com/cfq6a46hi8uO Please follow the link! https://www.hackerrank.com/challenges/write-a-function/problem

9th Mar 2019, 6:07 AM
Ashutosh Dash
Ashutosh Dash - avatar
5 Answers
+ 8
Ashutosh Dash Line 6 is currently: print('True') Instead of: return('True') So, when the print('True') line is called it will print 'True' and return nothing. Then line 11 is essentially the same as: print(None)
9th Mar 2019, 8:03 AM
David Carroll
David Carroll - avatar
+ 4
Ashutosh Dash Based on the Hackerrank question, the requirements for leap year are: - The year can be divided by 4 but not divided by 100. - Or the year can be divided by 400. Your code is only checking the year can be divided by 400. Here is a version with it working: https://code.sololearn.com/cOvc47LteQis/?ref=app
9th Mar 2019, 7:30 AM
David Carroll
David Carroll - avatar
+ 1
I'm not Anna but here I go. You're printing True if the year is divisible by both 4 and 100 (in other words, if it's divisible by 400). You're idea is not wrong, you're just missing the leap years that are not divisible by 400 (e.g. 2004, 2008, 2012). Add that to your code, and don't forget to check for divisibility by 100.
9th Mar 2019, 6:57 AM
Diego
Diego - avatar
+ 1
Diego David Carroll thanks for your response I want to know why there is "None" coming in output.
9th Mar 2019, 7:55 AM
Ashutosh Dash
Ashutosh Dash - avatar
0
Anna love listen from you!!
9th Mar 2019, 6:07 AM
Ashutosh Dash
Ashutosh Dash - avatar