title: How to extract a part of a list of strings?
body: <p>I have a list of strings and I want to extract the first 6 characters of each string and store them in a new list.  </p>
  
  <p>I can loop through the list and extract the first 6 characters and append them to a new list. </p>
  
  <pre><code>y = []
  for i in range(len(x)):
      y.append(int(x[i][0:6]))
  </code></pre>
  
  <p>I want to know if there is an elegant one line solution for that. 
  I tried the following:</p>
  
  <pre><code>y = x[:][0:6]
  </code></pre>
  
  <p>But it returns a list of the first 6 strings. </p>