I have a list
a=['10,20,30','30,45,90','40,56,80']
each element of the list is a string. I want to make a list of lists, such that it will look like this:
a=[[10,20,30],[30,45,90],[40,56,80]]
Any ideas? Thanks
You can do it using split as follows:
b = [map(int, i.split(',')) for i in a]
>>> print b
[[10,20,30],[30,45,90],[40,56,80]]
The split method splits the string on the specified sub-string, in this case: ','. A split without any arguments, such as string.split() will split the string on a whitespace character and then return a list.
ints now.