Weekday of a Specific Date
Write a Python function that accepts a string representing a date and returns the day of the week for that date. Assume the date string is in the format ‘YYYY-MM-DD’.
Input Data: Your function should accept a single string representing a date.
You can complete this challenge in any IDE or get started in this Google Colab notebook.
Explanation of Solution: The function
get_weekday uses the
strptime function from the
datetime module to convert the date string to a datetime object. The
strftime function is then used to format the datetime object as a string representing the day of the week (‘%A’).