-1

I have 2 str arrays, objects in are times formatted like HH:MM:SS. I am trying to do the subtraction of the corresponding members of the arrays.

difference[i]=time2[i]-time1[i]

I don't know what format to convert the str arrays to.

Thank you in advance for your time.

3 Answers3

0

I'd recommend using pendulum.

import pendulum
difference[i]= pendulum.parse(time2[i]).diff(time1[i]).in_hours()
-1

This should save it in difference as integer, if you want to have it in string as well, then just add everything after "=" into str()

difference[i] = int(time2[i]) - int(time1[i])
ŠOTO
  • 11