0

I want to write a python code that finds Sundays between 1.1.1500 and 31.12.1600 without using any library.

I have printed the dates in the following code.I try to find sunday divide seven but I think is not correct. How can I print the days corresponding to sunday without library?

start_date = date(1500, 1, 1)
end_date = date(1600, 12, 31)    # perhaps date.now()

delta = end_date - start_date   # returns timedelta

for i in range(delta.days + 1):
    date_ = start_date + timedelta(days=i)
    #print(date_.weekday())
   # print(date_.day)
    x=date_.day
    y=date_.month
    z = date_.year
   # print(x,y,z)
   # print(type(x))
    if(x%7==0):
        print(x,"sunday")
    else:
        #print("yeter")

**

Output: 7 1 1500 14 1 1500 21 1 1500 ..... ..... To 1600

**

Sachith Wickramaarachchi
  • 5,546
  • 6
  • 39
  • 68
ford
  • 29
  • 1
  • 3
  • 7

0 Answers0