Python Forum

Full Version: Fastest Way to declare this list.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to declare a list (a "matrix", in fact) by inserting new 2-dimensional lists into it, and i´m using append for that (code below):

M = []
for i in range (n): M.append([int(i) for i in input().split()])
Is there a quicker way to do this?
Can you show an example of the input and the result list?
[list(map(int, input().split())) for _ in range(n)]