python - How to use map function on nested lists and converting strings to integers? -


i need use map function in python(2.4.4) add 1 each item in list, tried converting strings integers.

line=[['10', '13\n'], ['3', '4\n'], ['5', '3\n'], ['1', '13']]  map(lambda x:(x+1),int(line)) 

is not working because of \n , nests?

well intent not clear not due \n.

see :

>>> line=[['10', '13\n'], ['3', '4\n'], ['5', '3\n'], ['1', '13']] >>> map(lambda x:([int(x[0])+1, int(x[1]) +1]),line) [[11, 14], [4, 5], [6, 4], [2, 14]] 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -