Question: I would like to be able to push each **|** into an array

Here is my function: 

```
def pyramide(lines):
    k = 1 * lines - 1 
    for i in range(0, lines): 
        for j in range(0, k): 
            print(end=" ") 
            k = k - 1
         for j in range(0, i+1): 
            print("|", end=" ") 
            print("\r")

lines = 5
pyramide(lines)

```

What I tried: 

```
for j in range(0, i+1): 
    each = print("|", end=" ") 
    array.push(each)
    print("\r")

```

But it doesn't seem to add it into an array, my question is how I can push each **|** into an array so I can delete it later 

Edit: 

expected input: 

```
pyramide(5)

```

expected output: 

```
    |
   | |
  | | |
 | | | |

```

Then I should be able to remove a **|** from each line by 

```
 stickDelete(3, 2) # first paramater is the line, second is how much | would like to delete 
    |
   | |

 | | | |

```

Answer: 
Split it in 2:

* a list of arrays holding the '|' 's (or other character)
* a function to print the 'pyramid' arrays

Wrapped in a class you get something like:

```
class CPyramide(object):

    def __init__(self, lines):
        self.pir = []
        # construct the array of arrays for the pyramid
        # each one holding the n-bars for a row
        for i in range(lines):
            # construct the array using a listcomprehension
            bars = ['|' for j in range(i+1)]
            self.pir.append(bars)

    def __str__(self):
        """print the pyramid"""
        o = ""
        # loop through all the rows that represent the pyramid
        # and use enumerate to have them numerical from 0 to len(pir)
        for i, L in enumerate(self.pir):
            # spaces decrease with increase of rows ...
            spaces = (len(self.pir) - i) * ' '
            # so, a line starts with the n-spaces
            o += spaces
            # appended with the bars of that row all in L
            o += ' '.join(L)
            # and a newline, which is definitely something else
            # then '\r' (on unix \r will show only one line when
            # using '\r'!)
            o += "\n"

        return o

    def stickDelete(self, line, n):
        self.pir[line] = self.pir[line][n:]

print("===============")
cpir = CPyramide(5)
print(cpir)
cpir.stickDelete(3, 2)
print(cpir)

```

Output:

```
===============
     | 
    | | 
   | | | 
  | | | | 
 | | | | | 

     | 
    | | 
   | | | 
  | | 
 | | | | | 

```
```html
def triangle(n):   
    k = 2*n - 2
    for i in range(0, n):   
        for j in range(0, k): 
            print(end=" ")  
        k = k - 1
        for j in range(0, i+1):  
            print("| ", end="") 
        print("\r")     
n = 5
triangle(n) 

this will return

D:\>st.py
        |
       | |
      | | |
     | | | |
    | | | | |
```