Forum Discussion

manuelaneena's avatar
manuelaneena
Occasional Contributor
6 years ago

appending values horizontally to a list

is there is a way to horizontally add items to a list.Normally it is added vertically.

  • manuelaneena's avatar
    manuelaneena
    6 years ago

    TanyaYatskovska 

    It was just a for loop.My requirement was to take out 4 values each from a list of 600+ values horizontally.I think I messed up  the question I asked here.Please find the code below.

    for m in range(0, (len(valueList)-1), 4):
    regexpattern=(".*")+re.escape(valueList[m])+(".*")+(valueList[m+1])+(".*")+re.escape(valueList[m+2])+(".*")+re.escape(valueList[m+3])+(".*")

     

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I'm not sure I understand the question.  What kind of list? What do you mean "horizontally" versus "vertically"? 

    • manuelaneena's avatar
      manuelaneena
      Occasional Contributor

      Dear Robert,

      I have created a set of values from a json file in a list which have around 700+ values.I wanted to rearrrange it to columns of 4.Could you please guide me for the same.

      Thank you.

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Are you inputting these values into columns in some table or something? Because, in "abstract" code, there really isn't much the idea of rows and columns.  Of course, I could be missing something here but I'm still not sure I understand your goal.