# Creating list np.arange

I want to create list, so I used:

```
x_ticks=np.arange(x1, x2, 6)
print(x_ticks)
print(type(x_ticks))
print(x_ticks[5])
```

The result is:

```
[-1.15e-14]
<class 'numpy.ndarray'>
Traceback (most recent call last):
File "el_motion.py", line 371, in <module>
print(x_ticks[5])
IndexError: index 5 is out of bounds for axis 0 with size 1
```

Why there are not 6 elements printed? Thank you

**EDIT**

How to plot small lines in 3d using this list and for cycle?

```
x1=-1.15e-14
x2=0.009e-14
x_ticks=np.linspace(x1, x2, 6)
print(x_ticks)
print(type(x_ticks))
print(x_ticks[5])
stepx=(x2-x1)/6
print(stepx)
for xi in range(1, 6):
ax.plot([xi*stepx, xi*stepx], [-6.3e-15, -6.4e-15], [0,0])
```

the result is one line that is not on the desired place.

### 2 Answers

My guess is that the difference between x1 and x2 is less that the provided step interval (6). For example:

```
np.arange(1, 5)
```

prints

```
[1, 2, 3, 4]
```

whereas for

```
np.arange(1, 5, 6)
```

6 is too large of a step, therefore it returns only the first value

```
[1]
```

np.linspace(x1, x2, 6) on the other hand, will return x1 one and x2 evenly spaced increments between, resulting in 6 numbers

William Herewini
posted this

## Have an answer?

JD

What are x1 and x2?