title: changing file name and extension using loop
body: <p>I need to change the name and extension of a series of files. The names are currently 'tmax.##.txt', but I need it to be 'tmax_##.txt'. Then, I want to change the .txt extension to .asc. I've tried the below code and the first loop works as expected to produce 'tmax_01'. The second loop runs, but produces unexpected results, 't'.</p>
  
  <pre><code>list_raw = 'tmax.01.txt', 'tmax.02.txt', 'tmax.03.txt'
  
  for i in list_raw:
      list_conv = i.replace('.','_')
  
  for i in list_conv:
  list_final = i.replace('_txt','.asc')
  </code></pre>
  
  <p>Any suggestions?</p>