title: How to convert a string that has newline characters in it into a list in Python?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2094176/split-a-string-in-python">split a string in python</a>  </p>
  </blockquote>
  
  
  
  <p>I want to change this:</p>
  
  <pre><code>str = 'blue\norange\nyellow\npink\nblack'
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>list = ['blue','orange', 'yellow', 'pink', 'black']
  </code></pre>
  
  <p>I tried some for and while loops and have not been able to do it. I just want the newline character to be removed while triggering to make the next element. I was told to use:</p>
  
  <pre><code>list(str)
  </code></pre>
  
  <p>which gives</p>
  
  <pre><code>['b', 'l', 'u', 'e', '\n', 'o', 'r', 'a', 'n', 'g', 'e', '\n', 'y', 'e', 'l', 'l', 'o', 'w', '\n', 'p', 'i', 'n', 'k', '\n', 'b', 'l', 'a', 'c', 'k']
  </code></pre>
  
  <p>After this I use <code>.remove()</code> but only one <code>'\n'</code> is removed and the code gets more complicated to spell the colors.</p>