python array sorting 1

python array sorting

n = 10
numbers = []
for i in range(1, n+1):
    numbers.append(i)
print(numbers)

Here is what the above code is Doing:
1. We create an empty list called numbers.
2. We create a for loop that iterates through the range of 1 to n+1.
3. We append the value of i to the list numbers.
4. We print the list numbers.

Similar Posts