title: TypeError:'int' object is not iterable when I try to iterate through my inner loop?
body: <p>I am not sure what the problem is with my loop structure. Maybe it's a naming problem since the count variable and SubElement names use the same variable. Any help is appreciated.</p>
  
  <pre><code>from xml.etree import ElementTree as ET
  
  root = ET.Element("painter")
  root.set('version', '1.0')
  linenum = 0
  pointnum = 0
  
  smpl_data = [[[20,40],(0,0,1,1)],[[10,50],(0,0,1,1)],[[78,89],(0,0,1,1)]]
  
  while linenum &lt;= len(smpl_data): #smpl_data change to self.lines
      elem_line = ET.SubElement(root,"line" + str(linenum), attrib={"r": "1", "g": "2", "b": "3", "a": "4"})                     
      elem_line.set("r", smpl_data[linenum][1][0])
      print elem_line.attrib.get("r")                      
      elem_line.set("g", smpl_data[linenum][1][1])
      print elem_line.attrib.get("g")
      elem_line.set("b", smpl_data[linenum][1][2])
      print elem_line.attrib.get("b")
      print elem_line.get("a")
      elem_line.set("a", smpl_data[linenum][1][3])
      print elem_line.attrib.get("a")
  
      for pointnum in linenum:
          elem_point = ET.SubElement("line" + str(linenum), "point" + str(pointnum), attrib={x: "10", y: "20"})
          print elem_point
          print elem_point.get("x")
          elem_point.set("x", smpl_data[linenum][0][0])
          print elem_point.attrib.get("x")
          print elem_point.get("y")
          elem_point.set("y", smpl_data[linenum][0][1])
          print elem_point.attrib.get("y")
          pointnum = pointnum + 1
     linenum = linenum + 1
  </code></pre>
  
  <p>I get the error right when it tries to begin iterating through the inner loop, for pointnum in linenum. Not sure why?</p>
  
  <p>I apologize for not being more clear.</p>
  
  <p>This is the full error:</p>
  
  <pre><code>  Traceback (most recent call last):
    File "C:\Users\joel\Desktop\open-autism-software\software\asd\pen\writexml.py", line 57, in &lt;module&gt;
    for pointnum in linenum:
    TypeError: 'int' object is not iterable
  </code></pre>
  
  <p>My goal in the full program is to be able to add all the specific (x,y) points as attributes to their respective SubElement (line). Each line is attached to the main root. However, the number of (x,y) points is variable with my persistent data because each line can be a different length. </p>
  
  <p>The XML doc should look something like this:</p>
  
  <pre><code>&lt;root&gt;
  &lt;line r="0", g="0", b="1", a="1"&gt;
      &lt;point x="20" y="30"&gt;
      &lt;point x="10" y="15"&gt;
      &lt;point x="15" y="25"&gt;
      ...
  &lt;/line&gt;
  &lt;line r="0", g"1", b="1", a="1"&gt;
      ...
  &lt;/line&gt;
  ...
  &lt;/root&gt;
  </code></pre>