title: Python errors when formatting strings that came from a list of strings?
body: <p>Given the contents of my file:</p>
  
  <pre><code>"ID","Name","Type 1","Type 2","Generation","Legendary"
  1,"Bulbasaur","Grass","Poison",1,"FALSE"
  6,"Charizard","Fire","Flying",1,"FALSE"
  4,"Charmander","Fire","",1,"FALSE"
  169,"Crobat","Poison","Flying",2,"FALSE"
  146,"Moltres","Fire","Flying",1,"TRUE"
  643,"Reshiram","Dragon","Fire",5,"TRUE"
  641,"Tornadus, (Incarnate Form)","Flying","",5,"TRUE"
  </code></pre>
  
  <p>I use readlines() to create a list of each string as its own line. </p>
  
  <p>Then I attempt to take those strings and format them to the following format:</p>
  
  <pre><code>'Bulbasaur': (1, 'Grass', 'Poison', 1, False)
  </code></pre>
  
  <p>I need to make sure the exact quotations are correct and that all lower cases and uppercases are correct. I also must ensure that the types are made into what they are needed.</p>
  
  <p>When I go to iterate or format the strings (ie strip and split), I am receiving a few errors: </p>
  
  <pre><code>TypeError: 'int' object is not iterable
  AttributeError: 'int' object has no attribute 'split'
  </code></pre>
  
  <p>I am seriously confused as to how this needs to work. My overall function runs but is not returning the right results. Example: it returns charmander's info in the dictionary instead of bulbasaur's. </p>
  
  <ul>
  <li>I need to take the results from readlines() and get each line as a string</li>
  <li>I need to format that string into the format provided above</li>
  <li>Then once I have that format, I need to make it into a dictionary. </li>
  </ul>
  
  <p>Here is my function which is really all over the place:</p>
  
  <pre><code>def read_info_file(filename): #accept file 
      file= open(filename)
      lines=file.readlines()[1:] #skip first header line
      d={}
      for line in lines:
          split_line=line.split(',') #get individual strings
          legendary=True
          if 'F' == split_line[-1].strip('"')[0]: #check last position if t or f to format legendary correctly
          legendary=False
  
          if len(split_line) &gt; 6:
              (k,v)=(split_line[1]+split_line[2].strip('"'),  #puts right order and removes excess quotations
   (int(split_line[0]),split_line[3].strip('"'),split_line[4].strip('"'),
          int(split_line[5]),legendary))
  
          else:
              (k,v)=(split_line[1].strip('"'),
  (int(split_line[0]),split_line[2].strip('"'),split_line[3].strip('"'),
              int(split_line[4]),legendary))
  
      d.update([(k,v)])
      file.close()
      return d
  </code></pre>