(May-04-2020, 11:20 AM)DeaD_EyE Wrote: In Python sequences are iterable. Also astr
is iterable.
Alist
,tuple
,set
,dict
, ..., consumes iterables.
greeting = "Hello World" print(list(greeting))So you can use this, to split the chars of a line, which represents the row (y coordinates).
Output:['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']
text = """ ******F**** *****W***** """.strip() # the text has a leading '\n' # and a tailing '\n' # strip removes whitespaces from left and right side of a str # also a newline is interpreted as whitespace. matrix2d = [list(line.strip()) for line in text.splitlines()] # iterate over lines, which are the rows # make a list from each row, which represents the columns # if you want to transpose the 2d matrix: matrix2d_transposed = list(zip(*matrix2d))
another way to sort of say what i need is
ls = ['string one' , 'string two']
ls2 = [[s,t,r,i,g, ,o,n,e], [,s,t,r,i,n,g, ,t,w,o]]
(May-04-2020, 12:10 PM)garry1415 Wrote:**X**(May-04-2020, 11:20 AM)DeaD_EyE Wrote: In Python sequences are iterable. Also astr
is iterable.
Alist
,tuple
,set
,dict
, ..., consumes iterables.
greeting = "Hello World" print(list(greeting))So you can use this, to split the chars of a line, which represents the row (y coordinates).
Output:['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']
text = """ ******F**** *****W***** """.strip() # the text has a leading '\n' # and a tailing '\n' # strip removes whitespaces from left and right side of a str # also a newline is interpreted as whitespace. matrix2d = [list(line.strip()) for line in text.splitlines()] # iterate over lines, which are the rows # make a list from each row, which represents the columns # if you want to transpose the 2d matrix: matrix2d_transposed = list(zip(*matrix2d))
another way to sort of say what i need is
ls = ['string one' , 'string two']
ls2 = [[s,t,r,i,g, ,o,n,e], [,s,t,r,i,n,g, ,t,w,o]]
* *
**Y**
thats what the board looks like i need to put it in cells if that makes sense