write unicode objects from loop to list in Python
<p>I have a loop that returns me unicode objects:</p>

<pre><code>for i in X:
print i

Output:  

  A
  B
  C
  ...
  Z
</code></pre>

<p>How can I make a list of these objects to get the folloving?</p>

<pre><code>['A', 'B', ..., 'Z']
</code></pre>

<p>If they were numbers, i'd do</p>

<pre><code>for i in X:
y=[]
i.append(y)
</code></pre>

<p>but here i get the error </p>

<pre><code>AttributeError: 'unicode' object has no attribute 'append'
</code></pre>

<p>If you are looping through a variable, you already know it is an iterable, such as a generator or list. First, you need to tell us the type of the <code>x</code> variable in your statement.</p>

<p>If your expected output is a list and <code>x</code> is not one, simply call the <code>list</code> function:</p>

<pre><code>new_list = list(x)
</code></pre>

<p>If it's necessary that you build the list in a loop for some reason, you should call the <code>append</code> function on a previously created list--not an item, as you do in your example:</p>

<pre><code>new_list = []
for i in x:
    new_list.append(i)
print (new_list)
</code></pre>

python list unicode append