I want to find out the following:
given a date (datetime
object), what is the corresponding day of the week?
For instance, Sunday is the first day, Mond
Below is the code to enter date in the format of DD-MM-YYYY you can change the input format by changing the order of '%d-%m-%Y' and also by changing the delimiter.
import datetime
try:
date = input()
date_time_obj = datetime.datetime.strptime(date, '%d-%m-%Y')
print(date_time_obj.strftime('%A'))
except ValueError:
print("Invalid date.")