+ 1

Why this code is not give correct output

The code is for finding the day of a date But this is not gi e correct date https://code.sololearn.com/ctvhOMkCQE05/?ref=app

30th Mar 2019, 8:06 AM
Jitendra
Jitendra - avatar
1 Odpowiedź
+ 1
Your ‘months’ list is missing a 31 at the end for December and I think you don’t need to do yy2 = yy - 1. Subtracting by 1 puts the day out by 1. Edit to add: on further inspection, I can see another couple of errors. Line 18 should be yy = (yy2 - yy2//4)*365 I believe. Also your algorithm is not yet complete. In the Gregorian calendar, years that end in ‘00’ are only leap years if the numbers before the zeroes are divisible by 4. So 1600 and 2000 are leap years (because 16 and 20 are multiples of 4) but 1700, 1800 and 1900 ate not leap years. As it stands, your algorithm doesn’t account for that.
30th Mar 2019, 9:13 AM
Russ
Russ - avatar