0

I am trying to remove the multiplicative properties that are in my loops as it complicates things up and makes the code more of a hassle on my end. Can anybody help me out and try to remove the multiplicative properties but still retain the same output

space = 't'
star = '*'
while 1:
    size = int(input("Enter the height of the pattern (must be greater than 0): "))
    if size > 0:
        break
    print("Invalid Entry!")
    

i = 0
while i < size:
    star_count = 2 * i - 1

    line = space * (size - i - 1)

    if i == 0 :
        line += "1"
    else :
        line += str(2 * i) + space

    line += (star + space) * star_count

    if i > 0 :
        line += str(2 * i + 1)
    i += 1

    print(line)

Output should be this if user input is 5

                1
            2   *   3
        4   *   *   *   5
    6   *   *   *   *   *   7
8   *   *   *   *   *   *   *   9
john Asked question May 13, 2021