title: How to overcome "TypeError: list indices must be integers or slices, not str" in for pa in data["result"]
body: <p>I face the following problem, for pa in data["result"] the following error is displayed "TypeError: list indices must be integers or slices, not str". Could you suggest me which kind of manipulation should I make to the code for letting it running without displaying the error?</p>
  
  <pre><code>with open("data/indicePA/indicePA.tsv", 'w') as f_indice_pa , open("data/indicePA/otherPA.tsv", 'w') as f_other:
          writer_indice_pa = csv.writer(f_indice_pa, delimiter ='\t')
          writer_other_pa = csv.writer(f_other, delimiter ='\t')
  
          count = 0
          res = ["cf", "cod_amm", "regione", "provincia", "comune", "indirizzo", "tipologia_istat", "tipologia_amm"]
          writer_indice_pa.writerow(res)
          writer_other_pa.writerow(["cf"])
  
          for pa in data["result"]:
              esito = pa["esitoUltimoTentativoAccessoUrl"]
              if esito == "successo":
                  cf = pa["codiceFiscale"]
  
                  if cf in cf_set_amm:
                      try:
                          cod_amm = df_amm.loc[df_amm['Cf'] == cf].iloc[0]['cod_amm']
                          take0 = df_amm.loc[df_amm['cod_amm'] == cod_amm].iloc[0]
                          regione = take0['Regione'].replace("\t", "")
                          provincia = str(take0['Provincia']).replace("\t", "")
                          comune = take0['Comune'].replace("\t", "")
                          indirizzo = take0['Indirizzo'].replace("\t", "")
                          tipologia_istat = take0['tipologia_istat'].replace("\t", "")
                          tipologia_amm = take0['tipologia_amm'].replace("\t", "")
  
                          res = [cf, cod_amm, regione, provincia, comune, indirizzo, tipologia_istat, tipologia_amm]
                          writer_indice_pa.writerow(res)
                      except: # catch *all* exceptions
                          print("CF in df_amm",cf)
                  elif cf in cf_set_serv_fatt:
                      try:
                          cod_amm = df_serv_fatt.loc[df_serv_fatt['Cf'] == cf].iloc[0]['cod_amm']
                          take0 = df_amm.loc[df_amm['cod_amm'] == cod_amm].iloc[0]
                          regione = take0['Regione'].replace("\t", "")
                          provincia = str(take0['Provincia']).replace("\t", "")
                          comune = take0['Comune'].replace("\t", "")
                          indirizzo = take0['Indirizzo'].replace("\t", "")
                          tipologia_istat = take0['tipologia_istat'].replace("\t", "")
                          tipologia_amm = take0["tipologia_amm"].replace("\t", "")
                          res = [cf, cod_amm, regione, provincia, comune, indirizzo, tipologia_istat, tipologia_amm]
                          writer_indice_pa.writerow(res)
                      except: # catch *all* exceptions
                          #e = sys.exc_info()[0]
                          print("CF in df_serv_fatt",cf)
                  else:
                      #print(cf, " is not present")
                      count = count + 1
                      writer_other_pa.writerow([cf])
                      #if(count % 100 == 0):
                          #print(cf)
  
          print("Totale cf non presenti in IndicePA: ", count)
          f_indice_pa.flush()   
          f_other.flush()
  
      I expect to obtain the following statement "Totale cf non presenti in IndicePA:  1148", because this code has been already run. But I face this problem. How to overcome it? Is there any manipulation that I can make to this original code?
  </code></pre>
  
  <p>Thanks for your help in advance. 
  It is possible to find a wider explanation of the code at the following link: <a href="https://github.com/fabiana001/anacAnalysis/blob/master/notebooks/1_Analisi_IndicePA_OpenConsip.ipynb" rel="nofollow noreferrer">link resource</a></p>