Calculate what day it will be 100 years

58 Views Asked by At

I'm trying to figure out how to calculate the day it will be in 100 years. I've written some python code that takes two inputs from the user, a year and day and then I'm trying to calculate what day of the week it will be in 100 years. I'm not supposed to use datetime but rather some logic that I am not grasping. Please advise how do I do this? Thank you.

Example output:

What is the year: 2022
What day is it: Wednesday
100 years from now will be a Monday

Python code:

days_of_the_week = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']

year = int(input('What is the year: '))
current_day = input('What day is it: ')

# account for leap years
if ( ( (year // 100) + 1) * 100 ) % 400 == 0:
    days = 36524
else:
    days = 36525
    
print(days)
days_ahead = days % 7

print('days ahead (days % 7)', days_ahead)
# index of the current day in the days_of_the_week list
idx = days_of_the_week.index(current_day)
# print day of the week in the list where the index position is days_ahead - idx - 1
print(days_of_the_week[ days_ahead - idx - 1])