# List of Numbers From 1 to N in Python

Hello guys. How are you all? I hope you fine. In this tutorial we will learn about how to make List of Numbers From 1 to N in Python. By using some particular methods you can make a list of numbers. Here you can make a list from 1 to your specific number. Its very easy and simple. Lets learn this by given below methods. This will make it easy for you.

## List of Numbers From 1 to N in Python

1. List of Numbers From 1 to N in Python

to make list of Numbers From 1 to N in Python just Use numpy.arrange(). numpy used for creat so many arrays. Here we will use numpy and arrange() function together. Here first we import numpy and then we will make np.arrange() function and give them number still which we want to print a list. By using this method you can print a list from 1 to N number. Lets learn this by given below exammple. I hope you guys like it. import numpy as np mylst = list(np.arange(1,8+1)) print(mylst)
Output : [1, 2, 3, 4, 5, 6, 7, 8]

2. How to make list of Numbers From 1 to N in Python

to make list of Numbers From 1 to N in Python just Use range().By using range() you can print list of numbers from 1 to N. the range() function has two parameters. First one is from where you want to star a list and the second one is the end of the list. You have to enter the both parameter and then use the range() function. It will give you the list of the numbers. Lets learn this by given below example:
mylst = list(range(1,8+1)) print(mylst) mylst = list(range(1,7+1)) print(mylst) Output : [1, 2, 3, 4, 5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7]

## Method 1: Use numpy.arrange()

numpy used for creat so many arrays. Here we will use numpy and arrange() function together. Here first we import numpy and then we will make np.arrange() function and give them number still which we want to print a list. By using this method you can print a list from 1 to N number. Lets learn this by given below exammple. I hope you guys like it.

import numpy as np
mylst = list(np.arange(1,8+1))
print(mylst)

Output :

[1, 2, 3, 4, 5, 6, 7, 8]

## Method 2: Use range()

By using range() you can print list of numbers from 1 to N. the range() function has two parameters. First one is from where you want to star a list and the second one is the end of the list. You have to enter the both parameter and then use the range() function. It will give you the list of the numbers. Lets learn this by given below example:

mylst = list(range(1,8+1))
print(mylst)

mylst = list(range(1,7+1))
print(mylst)

Output :

[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, 5, 6, 7]

## Method 3: Use user defined function

By using this method you can print a list from 1 to N. Here we will use for loop. and it will increase the value each time and append the value and will give the list you want. Here you have to enter the number you want at the end of the list. Thus you can print a list. Lets learn this.

def createList(n):
mylst = []
for i in range(n+1):
mylst.append(i)
return(mylst)

print(createList(8))

Output :

[0, 1, 2, 3, 4, 5, 6, 7, 8]

## Conlusion

Hope all 6 Method Are Useful For You. Comment Below Which Method You Used To Convert String To Datetime In Python. Thank You.