title: Python List Comprehension for a list with lists
body: <p>I am doing string replacement in a file and using the <a href="https://docs.python.org/3/library/csv.html" rel="nofollow noreferrer">csv</a> writer to write tabs in the output.  Using the csv writer means I need a well formed list to give to the csv writer for output.  I take a line of input that specifies tabs and newlines and place that into a list that the csv writer knows how to write out.</p>
  
  <p>I have the code below that actually does the task needed, what I would like to know is if that code can be further refined using list comprehension on the for loop to break tabs into their own lists and replace the existing item in the list.   Here is the code:</p>
  
  <pre><code>testInput = "\\t//blah/...\\t//blah_blah/...\\n\\t-//blah/...\\t//blah/...\\n\\t//blah/...\\t//blah_blah/...\\n\\t//blah/...\\t//blah/...\\n"
  
  new_lines = [z for z in testInput.split('\\n') if z]
  
  x=-1
  if testInput.find("\\t") &gt;= 0:
      for line in new_lines:
          x+=1
          lines = line.split("\\t")
          new_lines[x] = lines
  replacement_value = new_lines
  </code></pre>
  
  <p>With this code, the for for loop transforms new_lines from this:</p>
  
  <p><img src="https://i.imgur.com/mxcIjn4.png" alt="watchWindow"></p>
  
  <p>To this:</p>
  
  <p><img src="https://i.imgur.com/dhUu5o9.png" alt="NewWatchWindow"></p>
  
  <p>Can that for loop be re-written using list comprehension?</p>