Python Code Example: pattern reverse

Code Explanation

LineDescription
1for loop with the range 1 to 9 and a counter variable called i
2A second for loop, nested in the first one with the range 9 to i and the counter variable j. j is decremented by 1 in each loop pass
3The counter variable i of the first for loop is output
4Each time the second for loop is processed, the print() method is called to print a new line
for i in range(1, 9):
    for j in range(9, i, -1):
        print(i, end="")
    print()
Output
11111111
2222222
333333
44444
5555
666
77
8