for instance, i have a txt data called 'mazeline' like this:
abcd
cdae
korp
So i first made 3 lists:
mazeline = readmaze.split()
mline0 = list(mazeline[0])
mline1 = list(mazeline[1])
mline2 = list(mazeline[2])
So the 3 lists are:
mline0 = [a,b,c,d]
mline1 = [c,d,a,e]
mline2 = [k,o,r,p]
and i want to make a 2D array like this:
[[a,b,c,d],[c,d,a,e],[k,o,r,p]]
or is there any way that i can make a 2d array directly from the first data?
any suggestions? any help would be good.
Just put the lists inside another list
more simply, you can skip the intermediate variables and use a list comprehension
Try this list comprehension: