python - how to change the inner element tuple into list? -


>>> x=[[(1,2,3),(10,9,8)]] >>> x [[(1, 2, 3), (10, 9, 8)]] >>> 

i want change inner tuple element in x list ,that ,change x into

[[[1, 2, 3], [10, 9, 8]]] 

how can ? how can loop not list comprehension?

for unit in x:     cell in unit:         cell=list(cell) 

use list comprehension, this

x = [[(1, 2, 3), (10, 9, 8)]] print [[list(item) item in items] items in x] # [[[1, 2, 3], [10, 9, 8]]] 

this similar to

result = [] items in x:     temp = []     item in items:         temp.append(list(item))     result.append(temp) print result # [[[1, 2, 3], [10, 9, 8]]] 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -