I keep running into this error when I try to run my code.
Script:
start_date = int(input("Enter Start Date (YYYYDDMM)"))
end_date = int(input("Enter End Date (YYYYDDMM)"))
date_range = range(start_date, end_date + 1,1)
length = len(date_range)
i=0
for x in date_range:
hist_data = requests.get("https://covidtracking.com/api/v1/us/" + str(x[i]) + ".json")
for data in hist_data:
print(f"x - {data['state']} - Deaths: {data['death']} - Increase in Deaths: {data['deathIncrease']}")
i+=1
this is my traceback:
Traceback (most recent call last):
File "C:/Users/****/PycharmProjects/COVID_API/API_REQUESTS.py", line 18, in <module>
hist_data = requests.get("https://covidtracking.com/api/v1/us/" + str(x[i]) + ".json")
TypeError: 'int' object is not subscriptable
I was wondering how I would intake the dates as an int, populate the list for the dates in between, then feed the list through the for loop so I can get the data for each respective date. thank you!