(Solved) : Write Function Named Lastdayofmonth Userdatetime Given Userdatetime Function Return Strin Q42688653 . . .

Write a function named last_day_of_month(user_datetime). For anygiven user_datetime, the function should return a string with thelast day of the month formatted as day.month.year (weekday). Forinstance, for input of July 18th, 2018, the function should return31.07.2018 (Tuesday).

def last_day_of_month(user_datetime):
if user_datetime.month == 12:
# this is the case for December which is the last month and wecannot simply add one month to it and extract one day from thefirst day
# replace the user_datetime’s day with 31
last_day = …
else:
# this case is for all other months
# simply replace month with the next month (user_datetime.month +1)
# and day with 1
# then using timedelta subtract one day
last_day = …
return last_day.strftime(…)

# you should call the function like that:
last_day_of_month(datetime.datetime(2018, 8, 21))

Expert Answer


Answer to Write a function named last_day_of_month(user_datetime). For any given user_datetime, the function should return a strin…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?