title: Why wont this for loop let me use a count?
body: <p>So what im trying to do is have the code run through each element in the list 'data' which has values in it from another file, and start from the second element in the list. So i used a for loop with an index, i, and used data[i+1] which works usually. However i am getting an error when running.</p>
  
  <p><em>C = data[i+1]
  TypeError: can only concatenate str (not "int") to str</em></p>
  
  <p>It seems as though it does not like me doing 'i+1' but i dont understand why.</p>
  
  <p>The relevant code is below, i've only included the relevant parts of the function. Thanks for any help!</p>
  
  <p>Edit: What im trying to do is have the code loop through each item in the list 'data',where data is a list of values, im trying to make C equal to the value of the item in the 'i+1'th position. Is my use of a for loop incorrect here?</p>
  
  <pre><code>def correctFile(input,output):
      r = open(input + ".txt","r")
      w = open(output + ".txt","w")
      for l in r:
          line = []
          data = l.split("   ")
          yearmonth = data[0]
          datelist = yearmonth.split("/")
          for i in data:
              C = data[i+1]
              clean = C.lstrip(" ")
              line.append(str(clean))
  </code></pre>