>>> text = '2,4,6,8|10,12,14,16|18,20,22,24' >>> my_data = [x.split(',') for x in text.split('|')] >>> my_data [['2', '4', '6', '8'], ['10', '12', '14', '16'], ['18', '20', '22', '24']] >>> print my_data[1][2] 14
You might also want to convert each digit (fixed lines) to int , in which case I would do this:
>>> [[int(y) for y in x.split(',')] for x in text.split('|')] [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24]]
source share