Python Forum
Putting an array for each string that is printed to a loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Putting an array for each string that is printed to a loop
#1
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

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 
    |
   | |

 | | | |
Thanks for reading.
Reply


Messages In This Thread
Putting an array for each string that is printed to a loop - by ClaudioSimonetti - Feb-05-2019, 09:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  coma separator is printed on a new line for some reason tester_V 4 628 Feb-02-2024, 06:06 PM
Last Post: tester_V
  Loop over an an array of array Chendipeter 1 662 Nov-28-2023, 06:37 PM
Last Post: deanhystad
  How can histogram bins be separated and reduce number of labels printed on x-axis? cadena 1 970 Sep-07-2022, 09:47 AM
Last Post: Larz60+
  Loop through a list of string oldtrafford 4 1,579 Mar-24-2022, 05:30 PM
Last Post: deanhystad
  Loop through a list of string oldtrafford 3 1,822 Feb-15-2022, 04:42 PM
Last Post: snippsat
  loop for dynamic cut string - cleaner way? korenron 4 2,059 Nov-22-2021, 02:30 PM
Last Post: korenron
  I am trying to reverse a string using loop codinglearner 4 2,249 Sep-28-2021, 10:46 PM
Last Post: Pedroski55
  Convert String of an int array to a Numpy array of ints mdsousa 5 5,850 Apr-08-2021, 08:00 PM
Last Post: mdsousa
  Compare each element of an array in a logic statement without using a for loop leocsmith 3 6,080 Apr-01-2021, 07:57 PM
Last Post: deanhystad
  Loop different actions for an array Tibovdv 4 2,857 Mar-25-2021, 06:46 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020