Skip to content

Instantly share code, notes, and snippets.

@erdavids
Last active December 3, 2019 19:32
Show Gist options
  • Save erdavids/550c7391d4c3e63f86051d996fb6dee8 to your computer and use it in GitHub Desktop.
Save erdavids/550c7391d4c3e63f86051d996fb6dee8 to your computer and use it in GitHub Desktop.
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
def day_offset(day, offset):
return days[(days.index(day) + offset) % 7]
if __name__ == "__main__":
print(day_offset("Wednesday", 5)) # Monday
print(day_offset("Monday", 0)) # Monday
print(day_offset("Saturday", -1)) # Friday
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment