How to create an array of numbers 1 to N in Python

Arrays are called lists in Python. Creating a list of numbers 1 to N returns a list containing the numbers 1, whatever N is given to be, and all of the numbers in between those. For example, creating a list of numbers 1 to 4 returns [1, 2, 3, 4].

Solution for How to create an array of numbers 1 to N in Python : You can use range() to create a list of numbers 1 to N Call range(start, stop) to return a range object containing numbers start through stop – 1. Call list(range_object) to return a list of this object.


how-to-create-an-array-of-numbers-1-to-n-in-python