How to convert list to 20 column array

-1 python arrays list

I am making a program that takes a text file that looks something like this:

1
0
1
1
1

and converts it into a list:

['1','0','1','1','1']

The file has 400 lines so I want to convert it into an array that's 20 columns by 20 rows.

Ada*_*Er8 5

just use slicing to chunk it every 20 entries:

lines = [*range(1,401)]

rows_cols = [lines[i:i + 20] for i in range(0, len(lines), 20)]
Run Code Online (Sandbox Code Playgroud)