[Python] How should I take a matrix from input?

Discussão em 'Python' iniciado por Stack, Maio 7, 2025.

  1. Stack

    Stack Membro Participativo

    As we know input makes the inputs to string. How can I take matrix like this ([[1,2],[3,4]]) from input() by user and have it like a normal 2D list to do some thing on it.

    It should be like that

    data = input([[1,2],[3,4]])
    print(data)


    output : [[1,2],[3,4]]

    I tried this data = list(input()) but it was so wrong.

    Continue reading...

Compartilhe esta Página