I have a sh**y list of strings with weather info by hours, here it is:
bad_list =['00:00', '-2°C', '-6°C', '320°13 Km/h', 'N/A', '74%', '-6°C', '1025,0mb', '',
'01:00', '-1°C', '-3°C', '320°6 Km/h', 'N/A', '75%', '-5°C', '1024,0mb', '',
'02:00', '-3°C', '-5°C', '270°6 Km/h', 'N/A', '86%', '-5°C', '1023,0mb', '',
.....(skipped hours from 03 till 09)
'09:04', '9°C', '5°C', '290°35 Km/h', 'N/A', '66%', '3°C', '1022,0mb', '',
'10:00', '9°C', '5°C', '290°37 Km/h', 'N/A', '62%', '2°C', '1022,0mb', '',
'10:27', '10°C', '6°C', '280°39 Km/h', 'N/A', '58%', '2°C', '1023,0mb', '',
'11:02', '11°C', '11°C', '290°35 Km/h', 'N/A', '54%', '2°C', '1022,0mb', '',
'11:10', '12°C', '12°C', '290°37 Km/h', 'N/A', '47%', '1°C', '1022,0mb', '',
.....(skipped)
'23:00', '3°C', '3°C', 'N/A', '52%', '-6°C', '1020,0mb', '',
]
The problem is that in the list, hour strings are messy like the example, there is '10:00' and '10:27'. What I'm trying is to collect temp (next index string after an hour) for each hour (from 00:00 till 23:00). There are more than 24 strings for an hour (and the corresponding weather info!) in that list. So I was thinking to find the first occurrence for an hour and then to get the next index from the list as the corresponding temperature:
unique_time = ['00:','01:','02:','03:','04:','05:','06:','07:','08:','09:','10:','11:','12:','13:','14:','15:','16:',
'17:','18:','19:','20:','21:','22:','23:']
sorted_time_list = next(x for x in unique_time if x in bad_list) #not working
And to get +1 index string corresponding to sorted_time_list in bad_list. I know it sounds ugly but I want to get temp string (second element after hour string in bad_list) for only 24 hours.
I know it sounds little unclear. If need more details please shoot me :)