Question: write a program to calculate The difference between two datetime Ask the user to enter the first date in the format (YYY/MM/DD HH:MM) or

write a program to calculate The difference between two datetime Ask the user to enter the first date in the

write a program to calculate The difference between two datetime Ask the user to enter the first date in the format (YYY/MM/DD HH:MM) or any format you want . Ask the user to enter the second date in the format (YYY/MM/DD HH:MM) or any format you want If the second date is before the first day . . o just print an error message and quit the program Calculate the difference between the two dates o Print the difference in terms of days and hours ex: the difference is 3 days and 2 hours . Assume the user will enter bad dates o if the user enters bad data, you should print an elegant message and exit the program . the bad data can be 2020/04/31 # April 31st does not exist Seattle # you asked for a date, they entered a string o You can use try-except that you learned on Chapter 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Python import datetime Ask the user to enter the first date in the format YYYMMDD HHMM def getfirstdate while True try firstdate inputEnter the first date in the format YYYYMMDD HHMM firstdate datetim... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!