I will write how to create an array of numbers from 1 to 10 in Python. I look forward to working with you.

First, the basic array method.

```
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
```

Next, the method using the for statement.

```
a = []
for i in range(1, 11):
a.append(i)
```

```
a = [0]*10
for i in range(10):
a[i] = i+1
```

Method using while.

```
a = []
i = 1
while len(a) < 10:
a.append(i)
i += 1
```

```
a = [0]*10
i = 0
while not all(a):
a[i] = i+1
i += 1
```

Finally, the method of inclusion notation.

```
a = [i for i in range(1, 11)]
```

that's all. Thank you very much.

Recommended Posts