So say I have a list like so:
runtimes = ['24 min per ep',
'1 hr 55 min',
'24 min per ep',
'25 min per ep',
'23 min per ep',
'23 min per ep',
'23 min per ep',
'27 min per ep',
'24 min per ep',
'23 min per ep',
'24 min',
'22 min per ep',
'25 min per ep',
'24 min per ep',
'23 min per ep',
'24 min per ep',
'24 min per ep',
'24 min per ep',
'24 min per ep',
'1 hr 41 min',
'1 hr 27 min',
'25 min per ep',
'1 hr 22 min',
'30 min per ep',
'25 min per ep',
'1 hr 31 min',
'2 hr 4 min',
'24 min per ep',
'24 min per ep']
I want to convert these values into purely minutes:
I first thought it would be best to use two regex expressions like the ones below to replace the "1 hr" with "60 min" and then remove all the non-numerics, but this does not seem ideal.
re.sub("1 hr", "60 min", runtimes))
re.sub("\D", "", runtimes)
If someone knows a better way to do this it would be greatly appreciated.
Please let me know if you have any more questions.
Thank you for your help.
datetimemodule and perhaps a simple input parser.