IndexError: index 10 is out of bounds for axis 0 with size 10
<p>I am numerically setting up a mesh grid for the x-grid and x-vector and also time grid but again I have set up an array for <code>x</code> (position) which should only be between 0 and 20 and <code>t</code> (time) would be from 0 until 1000 thus in order to solve a Heat equation. But every time I want for e.g., I make the number of steps 10, I get an error:</p>

<pre><code>"Traceback (most recent call last):
File "/home/universe/Desktop/Python/Heat_1.py", line 33, in &lt;module&gt;
x[i] = a + i*h
IndexError: index 10 is out of bounds for axis 0 with size 10"
</code></pre>

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

<pre><code>from math import sin,pi
import numpy
import numpy as np

#Constant variables
N = int(input("Number of intervals in x (&lt;=20):"))
M = int(input("Number of time steps (&lt;=1000):" ))

#Some initialised varibles
a = 0.0
b = 1.0
t_min = 0.0
t_max = 0.5

# Array Variables
x = np.linspace(a,b, M)
t = np.linspace(t_min, t_max, M) 


#Some scalar variables
n = []                         # the number of x-steps
i, s = [], []                  # The position and time

# Get the number of x-steps to use
for n in range(0,N):
    if n &gt; 0 or n &lt;= N:
         continue

# Get the number of time steps to use
for m in range(0,M):
    if m &gt; 0 or n &lt;= M:
         continue

# Set up x-grid  and x-vector
h =(b-a)/n
for i in range(0,N+1):
    x[i] = a + i*h

# Set up time-grid
k = (t_max - t_min)/m
for s in range(0, M+1):
    t[s] = t_min + k*s

print(x,t)
</code></pre>