# pyramid number pattern
n = 5
for i in range(n):
for j in range(n - i - 1):
print(' ', end='')
for k in range(2 * i + 1):
print(k + 1, end='')
print()
row_len = int(input("Enter the length of the pyramid: "))
col_len = row_len*2 - 1 # calculate the maximum number of columns, depending on the row_len
for row in range(row_len):
nb_whitespaces = col_len//2 - row # calculate number of whitespaces that should be prints at first of each row
nb_asterisk = row+1 # calculate how many Asterisk that should be prints for each row
print(nb_whitespaces * " " + "* " * nb_asterisk)
# By Omar Alanazi
for row in range(row_len := int(input("Enter the length of the pyramid: "))):
print(((row_len * 2 - 1) // 2 - row) * " " + "* " * (row + 1))
# By Omar Alanazi
# Output example (if user enters 3)
# *
# * *
#* * *
rows = int(input("Enter number of rows: "))
for i in range(rows):
for j in range(i+1):
print("* ", end="")
print("
")
n = 3
for i in range(1, n+1):
print(f"{' '*(n-i)}{' *'*i}"[1:])
# Output:
# *
# * *
#* * *