I've an arrays of arrays called arr
and I want to split the second value of each array. This means, if I've 0-6
I would like to modify it to '0','6'
What I have:
arr = [['PROVEEDOR', '0-6', '11111'], ['tiempo ida pulidor', '6-14', '33333']]
What I would like to have:
arr = [['PROVEEDOR', '0', '6', '11111'], ['tiempo ida pulidor', '6', '14', '33333']]
How can I do this conversion? It's always the second value, and always have two numbers. I know I've to use .split('-')
but I know dont know to make it work here to make the replacement, as I've to iterate between all the arrays included in arr
.
Thanks in advance.
If you want to do it inplace:
In [83]: arr = [['PROVEEDOR', '0-6', '11111'], ['tiempo ida pulidor', '6-14', '33333']]
In [84]: for i in arr:
...: i[1:2]=i[1].split('-')
In [85]: arr
Out[85]: [['PROVEEDOR', '0', '6', '11111'], ['tiempo ida pulidor', '6', '14', '33333']]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With