I have a dictionary like this:
> { "Country1": {"time": [1/22/20, 1/23/20...], "cases":[0,10,20,...]},
> "Country2": {"time": [1/22/20, 1/23/20...], "cases":[0,10,20,...]},
> .... }
I want to drop the dates higher than a given date and their respective cases. I've tried with this, but it fails because of IndexError: list index out of range. How would yo do it?
for i in (range(len(Country_Region))):
for j in (range(len(Countries_Dict[i][Country_Region[i]]['time']))):
if datetime.strptime(Countries_Dict[i][Country_Region[i]]['time'][j], '%m/%d/%y') > datetime.strptime(date, '%m-%d-%y'):
Countries_Dict[i][Country_Region[i]]['time'].pop(j)
Countries_Dict[i][Country_Region[i]]['cases'].pop(j)
Dates are in string format, and the desired output is the same dictionary as before without the dates higher than a given date and their respective cases.