# Arup Guha
# 6/19/2017
# Stars program to practice nested loops.

QUIT = 7

def main():

    menu()
    choice = int(input("What is your choice?\n"))

    # Continue printing until the user quits.
    while choice != QUIT:

        # All designs take in a character, so do this first.
        ch = input("What character do you want for your design?\n")

        # First choice - parallelogram
        if choice == 1:
            rows = int(input("How many rows in your parallelogram?\n"))
            cols = int(input("How many columns in your parallelogram?\n"))
            parallelogram(rows, cols, ch)

        # Second choice - right triangle, left justified
        elif choice == 2:
            n = int(input("How many rows for your left justified right triangle?\n"))
            rightTri(n, ch)

        # Third choice - right triangle, right justified
        elif choice == 3:
            n = int(input("How many rows for your right justified right triangle?\n"))
            rightJustifiedTri(n, ch)

        elif choice == 4:
            n = int(input("How many rows for your back right triangle?\n"))
            backRightTri(n, ch)

        elif choice == 5:
            n = int(input("How wide is your sideways pyramid?\n"))
            sidewaysPyramid(n, ch)

        elif choice == 6:
            n = int(input("How tall is your pyramid?\n"))
            pyramid(n, ch) 

        # Error message.
        elif choice != QUIT:
            print("Sorry, that was an invalid choice.")

        # Get next choice.
        menu()
        choice = int(input("What is your choice?\n"))

def menu():

    print("Please choose one of the following options:")
    print("1. Print a parallelogram.")
    print("2. Print a left justified right triangle.")
    print("3. Print a right justified right triangle.")
    print("4. Print a back right triangle.")
    print("5. Print a sideways pyramid.")
    print("6. Print a regular pyramid.")
    #print("6. Print a diamond.")
    print("7. Quit")

def pyramid(n, c):

    starcnt = 1

    # Looping through # of spaces on each line. n-1,n-2,...,0
    for spaces in range(n-1,-1,-1):

        # Print spaces then stars.
        print(" "*spaces, end="")
        print(c*starcnt, end="")
        print()

        # Update # of stars for next row.
        starcnt += 2
    
# Prints out a left justified triangle of n rows using character c.
def rightTri(n, c):

    # Print out row i.
    for i in range(1,n+1):

        # We need i copies of character c.
        for j in range(i):
            print(c,end="")
        print()

# Prints out a left justified triangle of n rows using character c.
def backRightTri(n, c):

    # Print out n, then n-1, n-2 of char c on each row...
    for i in range(n,0,-1):

        # We need i copies of character c.
        for j in range(i):
            print(c,end="")
        print()

def sidewaysPyramid(n, c):
    rightTri(n, c)
    backRightTri(n-1,c)

# Prints out a right justifed triangle of n rows using character c.
def rightJustifiedTri(n, c):

    # i is the row number.
    for i in range(1, n+1):

        # Print n-i spaces
        for j in range(n-i):
            print(" ", end="")

        # Print i copies of character c.
        for j in range(i):
            print(c, end="")

        # Go to the new line.
        print()

# Prints a parallelogram with rows # of rows, cols # of cols using
# character c.
def parallelogram(rows, cols, c):

    # Go through each row.
    for i in range(rows):

        # Print i spaces.
        for j in range(i):
            print(" ", end="")

        # Print cols copies of character c.
        for j in range(cols):
            print(c, end ="")

        # Go to the next line.
        print()

main()
