Difference of times. | SoloLearn: Learn to code for FREE!


Difference of times.

Given the values of the two moments in time in the same day: hours, minutes and seconds for each of the time moments. It is known that the second moment in time happened not earlier than the first one. Find how many seconds passed between these two moments of time. Input 1 hours 2 minutes 30 seconds 1 3 20 Output 50 Please don't post any code. Not a code request question. What is pseudo code?

1/28/2020 7:34:11 AM


2 Answers

New Answer


Store the 3 integers in different vars. Lets say H (hours), M (min), S (sec). Convert both times to seconds, knowing that 1 hour = 60 min = 3600 sec. Use substraction to know the difference. Remember to do (bigger value - smaller value) and not the other way


Check also datetime.timedelta (in standard library) https://docs.python.org/3/library/datetime.html