Create a pyramid pattern:

 def create_pyramid(rows):

for i in range(rows): for j in range(rows-i-1): print(" ", end="") for j in range(i+1): print("* ", end="") print() rows = int(input("Enter the number of rows for the pyramid: ")) create_pyramid(rows) In this program, we define a `create_pyramid` function that takes the number of rows as an argument. Using two nested `for` loops, we iterate over each row and print the appropriate number of spaces and asterisks to create the pyramid pattern. Finally, we prompt the user to enter the number of rows and call the `create_pyramid` function with that input.

Comments

Popular posts from this blog

Ecommerce website

Yes, Python is an object-oriented programming (OOP) language, but it is also a multi-paradigm language

Your task is to find the missing number.