I was asked to create a program that calculates the number of Sundays inbetween 2 dates! I have been searching numerous articles and documentation but I still have a hard time understanding syntax. (2 months into my coding course with 0 technology and computer experience.)
I am having trouble understanding the logic of how to associate the calendar with the days inside the Dictionary. My current code is as follows :
def difference_between_days():
daysDict = {0 : "Monday",1: "Tuesday",2: "Wedensday",3: "Thursday",4: "Friday",5:
"Saturday",6: "Sunday"}
first_date = date(2021,7,28)
end_date = date(2022,7,28)
difference_between_dates = end_date - first_date
print(f"There are {difference_between_dates.days} days inbetween the two dates!")
d = date.weekday(first_date)
dd = daysDict[d]
print(f"The first date selected is a : {dd}")
difference_between_days()
edit: When using certain functions such as .isoweekday I run into problems printing because it returns me something like this "<built-in method isoweekday of datetime.date object at 0x000001EB956FA0F0>" and I still have not reached classes yet!