Hi All
I have written following Python Function which should return Day, when year, month & date is provided to function.
For Testing, I have limit it to 3 years & then call it using for loop. But it always return “Saturday”.
What’s wrong in function.
Code:
def dayOfYear(y,m,d):
if y in [2018,2019,2020]:
if m in [1,2,3]:
if d in [31,28,1]:
return(‘Saturday’)
else:
return(‘Thursday’)
else:
return(‘Sunday’)
else:
return(None)
for i in range(len(testYears)):
yr = testYears[i]
mo = testMonths[i]
dn = testDaysNo[i]
td = testDays[i]
print(yr, mo, dn, td, " -> “, end=”")
result = dayOfYear(yr,mo,dn)
if result == testDays[i]:
print(“OK”)
else:
print(“Failed”)