I need to create a hollow pyramid with a solid top layer like so:
Height: 5
*
***
* *
* *
*********
Also needs a user input for height/number of rows, so it can't just be hardcoded, for example with a height of 4:
*
***
* *
*******
Using this code I received this output with no solid layer on top:
*
* *
* *
* *
*********
n = 5
for i in range(n):
for j in range(n - i - 1):
print(' ', end='')
for k in range(2 * i + 1):
if k == 0 or k == 2 * i:
print('*', end='')
else:
if i == n - 1:
print('*', end='')
else:
print(' ', end='')
print()
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)