It is very simple, since lines and files are also iterable:
with open('input.txt') as matrixfile: matrix = [list(line.strip()) for line in matrixfile]
list() on a line turns it into a list of individual characters; we use .strip() to remove extra spaces, including a new line. The open matrixfile object is matrixfile , so we can iterate over it to process all the rows.
Result:
>>> matrix [['b', '-', '-', '-', 'd'], ['-', 'd', '-', '-', 'd'], ['-', '-', 'd', 'd', '-'], ['-', '-', 'd', '-', '-'], ['-', '-', '-', '-', 'd']] >>> matrix[0][2] '-'
source share