list indices must be integers, not str
<pre><code>class targil4(object):
    def plus():
        x=list(raw_input('enter 4 digit Num '))
        print x
        for i in x:
            int(x[i])
            x[i]+=1
        print x

    plus()
</code></pre>

<p>this is my code, I try to get input of 4 digits from user, then to add 1 to each digit, and print it back. When I run this code i get the massage:</p>

<pre><code>Traceback (most recent call last):
['1', '2', '3', '4']
  File "C:/Users/Maymon/PycharmProjects/untitled4/targil4.py", line 1, in &lt;module&gt;
class targil4(object):
  File "C:/Users/Maymon/PycharmProjects/untitled4/targil4.py", line 10, in   targil4
    plus()
  File "C:/Users/Maymon/PycharmProjects/untitled4/targil4.py", line 6, plus
  int(x[i])
TypeError: list indices must be integers, not str

Process finished with exit code 1
</code></pre>

<p>You can also use <a href="http://www.secnetix.de/olli/Python/list_comprehensions.hawk" rel="nofollow">list comprehension</a> and do</p>

<pre><code>y = [int(i) + 1 for i in x]
print y
</code></pre>

python string list integer indices