[Python] Making a nested list from a list of strings

Discussão em 'Python' iniciado por Stack, Agosto 11, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list of strings (from user input), and I want to make each string into a list, then put it into another list.

    This is my list of strings

    trial = ['Natural', 'Left', 'Right']


    I have made each string into a list using a for loop:

    for i in trial:
    globals() = list() # Returns dictionary with list of trials


    This command correctly makes each string into a list, but I need this list to be nested into a different list, like this:

    Output = [
    Natural[:],
    Left[:],
    Right[:]
    ]

    Continue reading...

Compartilhe esta Página