I\'m new to python and confused about converting a string to a list. I\'m unsure how to create a list within a list to accomplish the following:
Ex.
>>> strs = '2,4,6,8|10,12,14,16|18,20,22,24' >>> strs1=strs.split('|') >>> [map(int,x.split(',')) for x in strs1] [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24]]
Note: for python 3.x use list(map(int,x.split(','))), as map() returns a map object in python 3.x
list(map(int,x.split(',')))
map()