Skip to content

Instantly share code, notes, and snippets.

@computer-tutor
Created April 27, 2020 04:22
Show Gist options
  • Save computer-tutor/5332b42ec4e5e8d496e40bbf4fe96d45 to your computer and use it in GitHub Desktop.
Save computer-tutor/5332b42ec4e5e8d496e40bbf4fe96d45 to your computer and use it in GitHub Desktop.
def numberedDay(firstDay, dayNumber):
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
firstIndex = days.index(firstDay)
endIndex = (firstIndex + int(dayNumber) - 1) % 7
return days[endIndex]
year = input("Year: ")
firstDay = input("First day of the year (e.g. 'Monday'): ")
dayNumber = input("Day number: ")
if dayNumber not in range(2,366):
print("Invalid")
else:
print(numberedDay(firstDay, dayNumber))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment