Python Program to print the number from 1 to N by the intervals of the 10 numbers

Python program to print the numbers in the intervals by using the for loop

Exmaple:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100


Explanation of the following code:

  1. First we take the input by the user using the input() and int() function.
  2. Then we will iterate the for loop in such a way that the difference detween the number is 10.
  3. Then we will iterate the nested loop from i to i+10.
  4. Then we will print the nested loop with end operator.

n = int(input("Enter"))

for i in range(1,n+1,10):

    for j in range(i,i+10):

        print(j, end=" ")

    print()


If you have better solution than me then comment it.
Next Post Previous Post
2 Comments
  • Python
    Python March 8, 2021 at 12:21 PM

    Interesting post thanks.
    Python Online Training

  • High Technologies Solutions
    High Technologies Solutions March 13, 2021 at 2:19 PM

    Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective.

    Python Training Institute in Delhi

Add Comment
comment url