Build the rows
The outer counter x selects both the row number and the number of leading spaces to remove.
The right-aligned rows repeat their row number, growing from one 1 to five 5s.
The outer counter x selects both the row number and the number of leading spaces to remove.
The first inner loop adds alignment spaces; the second prints x once for every column in the row.
The inner print calls use end="" to keep values on the same line. The final empty print() moves to the next row.