Use str.splitlines
with either map
or a list comprehension
:
Using map
:
>>> map(list, design.splitlines())
[['x', 'x', 'x'], ['y', 'x', 'x'], ['x', 'y', 'x']]
List Comprehension:
>>> [list(x) for x in design.splitlines()]
[['x', 'x', 'x'], ['y', 'x', 'x'], ['x', 'y', 'x']]