Something easy got wrong
<p>English is not my strong language, please considerate it.</p>

<p>What I'm trying to do is make a 3x3, 4x4 or 5x5 matrix of "~" signs, that would get replaced by "X" 3 times,</p>

<p>Depending on coordinates given by x and y inputs, appended in s=[]</p>

<p>So for example if I have a matrix 3x3</p>

<pre><code>~~~
~~~
~~~
</code></pre>

<p>And coordinate (0,0),</p>

<p>The result should be:</p>

<pre><code>X~~
~~~
~~~
</code></pre>

<p>As easy as it sounds it's not easy for me still, I get problem even if my code seems logical to me.</p>

<pre><code>&gt; IndexError: list index out of range
</code></pre>

<p>This is my code:</p>

<pre><code>a = []

n=0
while n&lt;3 or n&gt;5:
    n=int(raw_input("type matrix: "))
for i in range (n):
    for j in range (n):
        print "~",
    print "\n",
def zdruzi(a):
    for row in a:
        print " ".join(row)
zdruzi(a)

s = []
for i in range(3):
    x=int(raw_input("x: "))
    y=int(raw_input("y: "))
    s.append(int(x))
    s.append(int(y))
    a[int(x)][int(y)]="X"

    if (x&lt;0) or (x&gt;(n-1)):
        print "not good"
        break

    print a
</code></pre>
