I have a nested list of strings. I want to change the first component of the nested list to integer, second to float.
>>> mylist = [['1','2','3'],['5','6','7']]
>>> datl3 = [[int(x) for x in line[0]] + line[1:] for line in mylist]
>>> type(datl3[0][0])
<type 'int'>
>>>
>>> # turn second element to float
... datl4 = [line[0] + [float(x) for x in line[1]] + line[2] for line in datl3]
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'list'
How I can I change the second component to float?