I'm trying to count the number of national holidays N
in each city in a .json
file and I keep getting the error TypeError: string indices must be integers
.
I've read a bunch of other posts about this error and I can't really find anything that helps. I'm assuming its related to how I'm pulling the .json
file?
(encoding for non-english letters in file)
import json
world_hol_data = json.load(open("holiday_data.json", "r", encoding="utf8"))
total_national_hol = 0
for cont in world_hol_data:
for city in cont:
if city["type"] == "N":
total_national_hol += 1
print(total_national_hol)