'float' object is not iterable error
<p>I am trying to get a a variable that reads out a load value (given in xml document) for a given length of a time (also a list of values). The list for t is from a value 'start' to 'end' with an interval of 15 min. Essentially what I want is that I want one load value to print for the entire length of its respective time list. So if its time list is [0 15 30 45 60] then I want its load value to be in a list repeating 5 times. The xml document and code I am running are below and I keep getting an error with my potW assignment saying "'float' object is not iterable." I know this is a lot but any suggestions? </p>

<pre><code>import xml.etree.ElementTree as ET 
import os

class WaterModel:

    def __init__(self,fn):

        self.tree = ET.parse(fn)
        self.root = self.tree.getroot()

        self.title, self.start, self.end, self.load, self.duration, self.Type = [],[],[],[],[],[]

        for child in self.root:
            self.title.append(child.find('title').text)

            sh = int(child.find('startHour').text)
            sm = int(child.find('startMinute').text)
            self.duration.append(int(child.find('duration').text))
            self.start.append(sh*60+sm)
            self.end.append(self.start[-1] + self.duration[-1])
            self.Type.append(child.find('Type').text)
            self.load.append(float(child.find('load').text))


    def Wp(self):

        greyW = 0  
        for i in range(len(self.root)):
            if self.Type[i] == 'greywater':
                greyW += self.load[i]*self.duration[i]

        t = range(self.start[i], self.end[i]+1, 15)  
        for i in range(len(self.root)):
            for j in range(len(t)):
                if self.Type[i] == 'potable':
                    potW = [a for a in self.load[j]]

fn = 'SD2017NominalWaterUse.xml'
a = WaterModel(fn)
b = a.Wp()
print(b) 
</code></pre>

<p>xml file 'SD2017NominalWaterUse.xml' that is read into the code above:</p>

<pre><code>&lt;WaterNominalDay&gt;

&lt;event&gt;
&lt;title&gt;Evening Washer&lt;/title&gt;
&lt;Type&gt;greywater&lt;/Type&gt;
&lt;startHour&gt;19&lt;/startHour&gt;
&lt;startMinute&gt;30&lt;/startMinute&gt;
&lt;duration units = 'min'&gt;270&lt;/duration&gt;
&lt;load units = 'gal/min'&gt;.051852&lt;/load&gt;
&lt;comment&gt;
''
&lt;/comment&gt;
&lt;/event&gt; 

&lt;event&gt;
&lt;title&gt;Morning Cooking&lt;/title&gt;
&lt;Type&gt;potable&lt;/Type&gt;
&lt;startHour&gt;7&lt;/startHour&gt;
&lt;startMinute&gt;30&lt;/startMinute&gt;
&lt;duration units = 'min'&gt;180&lt;/duration&gt;
&lt;load units = 'gal/min'&gt;.003331&lt;/load&gt;
&lt;comment&gt;
'5 lb water is .5995 gal'
&lt;/comment&gt; 
&lt;/event&gt;

&lt;event&gt;
&lt;title&gt;Evening Cooking&lt;/title&gt;
&lt;Type&gt;potable&lt;/Type&gt;
&lt;startHour&gt;19&lt;/startHour&gt;
&lt;startMinute&gt;30&lt;/startMinute&gt;
&lt;duration units = 'min'&gt;180&lt;/duration&gt;
&lt;load units = 'gal/min'&gt;.003331&lt;/load&gt;
&lt;comment&gt;
'5 lb water is .5995 gal'
&lt;/comment&gt; 
&lt;/event&gt;


&lt;event&gt;
&lt;title&gt;Leaks&lt;/title&gt;
&lt;Type&gt;potable&lt;/Type&gt;
&lt;startHour&gt;0&lt;/startHour&gt;
&lt;startMinute&gt;00&lt;/startMinute&gt;
&lt;duration units = 'min'&gt;1440&lt;/duration&gt;
&lt;load units = 'gal/min'&gt;.006944&lt;/load&gt;
&lt;comment&gt;
''
&lt;/comment&gt; 
&lt;/event&gt;

&lt;/WaterNominalDay&gt;
</code></pre>

<p><code>self.load</code> i an array of <code>float</code>s, so <code>self.load[j]</code> will be a float, which is what you are trying to iterate over; hence the error message.</p>

python xml list floating-point