IndexError: string index out of range (enumerate)
<p>Okay so I have no idea what the problem is here.  Everything I've read basically addresses the range not ending, thus the error, but that doesn't make sense to me since this is a fixed loop.  </p>

<p>I'm simply trying to take a string, and throw each letter into a list one at a time.  What am I missing?</p>

<pre><code>&gt;&gt;&gt; name = "Chris"
&gt;&gt;&gt; 
&gt;&gt;&gt; my_list = []
&gt;&gt;&gt; 
&gt;&gt;&gt; for key, value in enumerate(name):
...     my_list.append(value[key])
...     print (my_list)
...
</code></pre>

<p>The error I'm receiving:</p>

<pre><code>['C']
Traceback (most recent call last):
 File "&lt;pyshell#7&gt;", line 2, in &lt;module&gt;
 my_list.append(value[key])
IndexError: string index out of range
</code></pre>

<p>What you are missing is that <code>value</code> is a single element string. Indexing at positions <code>!= 0</code> will result in an <code>IndexError</code>; during your first iteration that's what happens.</p>

<p>If you want to create it with your for loop, just append the value immediately:</p>

<pre><code>for key, value in enumerate(name):
    my_list.append(value)
</code></pre>

<p>Of course, <code>enumerate</code> is by no means required here, this can be simplified by calling <code>list</code> and supplying the string in question; Python will then create a list containing the contents of the string for you:</p>

<pre><code>my_list = list(name)
</code></pre>

<p>For <code>Python 3.x</code> you can also unpack in a <code>list</code> literal with <code>*</code>:</p>

<pre><code>my_list = [*name]
</code></pre>

<p>In all supplied snippets, the result of the operations is <code>['C', 'h', 'r', 'i', 's']</code> as required.</p>

python python-3.x