Apr-26-2020, 09:25 PM
(This post was last modified: Apr-26-2020, 09:27 PM by prothej227.)
Here's my way of solving the problem. Since unlike C, printing str/int is directly concatenated after the loop, while in Python, the string is printed in newline. To solve this, i just created an output string "star" and then appended all the necessary data created by the loop.
row = int(input("Input the number of rows of your pyramid: ")) j = int() k = int() s = int() star = str() for j in range(1, row + 1): for s in range(row - j,0, -1): star += str(" ") for k in range(0, 2*j - 1): star +=str("*") star += str("\n") print(star)