spaces = i #The number of spaces in the beginning of row.
row = [j+1 for j in range(6-i)] + [(6-i-1)-j for j in range(6-i-1)] #Add numbers into row.
row_string = ' '.join(map(str, row)) #Convert list to string. Use map to turn ints in list to strings.
for j in range(spaces):
row_string = ' ' + ' ' + row_string
print(row_string)
1 votes Thanks 7
manamperi344
The code doesn't look nice when I paste is here... (I guess the answer box isn't meant to contain code, but oh well.) Hope you like this :)
Answers & Comments
for i in range(6):
spaces = i #The number of spaces in the beginning of row.
row = [j+1 for j in range(6-i)] + [(6-i-1)-j for j in range(6-i-1)] #Add numbers into row.
row_string = ' '.join(map(str, row)) #Convert list to string. Use map to turn ints in list to strings.
for j in range(spaces):
row_string = ' ' + ' ' + row_string
print(row_string)