Untitled

 avatar
unknown
plain_text
10 months ago
614 B
4
Indexable
from datetime import datetime

def find_day_of_week(date_string):
    # Parse the date string into a datetime object
    date_obj = datetime.strptime(date_string, '%Y-%m-%d')
    
    # Get the day of the week as an integer (Monday is 0 and Sunday is 6)
    day_of_week = date_obj.weekday()
    
    # List of days of the week
    days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    
    # Return the day of the week as a string
    return days[day_of_week]

# Example usage:
date_string = '2024-07-02'
print(find_day_of_week(date_string))  # Output: Monday
Editor is loading...
Leave a Comment