if data1.has_key('M_Flag')=="U": AttributeError: 'str' object has no attribute 'has_key' :     import datetime
    import xml.etree.cElementTree as etree
    import xlsxwriter
    import os
    from csv import DictWriter
    import urllib2
    import time, sys
    import pandas as pd

    url = "http://farmer.gov.in/ForecastService.asmx/forecastservice?date=16-08-2017"
    response = urllib2.urlopen(url)
    xmlDocData = response.read()
    xmlDocTree = etree.XML(xmlDocData)
    sections = ['Srno',
    'State','Statecd',
    'District','IssuedOn','Day','normal_rainfall',
    'normal_temp_max',
    'normal_temp_min','normal_cloud_cover',
    'normal_rh_max','normal_rh_min',
    'normal_windspeed','normal_winddirection',
    'M_rainfall','M_tempmax',
    'M_Cloudcover','M_rhmax',
    'M_rhmin','M_Windspeed',
    'M_Winddirection','M_Flag']
    fetched = dict()
    for sec in sections:
        fetched[sec]=[]
        for item in xmlDocTree.iter(sec):
            fetched[sec].append(item.text)
    workbook = xlsxwriter.Workbook("data.xlsx")
    worksheet = workbook.add_worksheet()
    row = 0
    col = 0
    for sec in sections:
        worksheet.write(row, col, str(sec) )
        col = col+1
    row = 1
    col=0
    maharashtra = []
    maharashtradata = []
    for sec in sections:
        row = 1
        for item in xmlDocTree.iter( sec ):
            if "AHMEDNAGAR" in item.text:
                maharashtra.append(row)
            row = row + 1
        col = col+1
    for entry in maharashtra:
        col=0
        entrydata = {}
        for sec in sections:
            entrydata[sec] = fetched[sec][entry]
            col = col + 1
        #maharashtradata.append(entrydata)
        for data1 in entrydata:
            if data1.has_key('M_Flag')=="U":
                print "Hello"
    row = 1
    col=0
    for sec in sections:
        row=1
        for data in maharashtradata:
            worksheet.write(row, col, data[sec])
            row = row + 1
        col = col+1
    workbook.close()

I am trying to extract data from XML and applying filters I am successfully able put one filter as "if "AHMEDNAGAR" in item.text:" but not able to apply multiple filters 
I am getting below error!
Where am I getting wrong?

if data1.has_key('M_Flag')=="U":

AttributeError: 'str' object has no attribute 'has_key'

