python - Remove quotes from second items in nested list -
i need remove quotes second items in nested list. example, change:
a = [['first', '41'], ['second', '0'], ['third', '12']] to:
[['first', 41], ['second', 0], ['third', 12]] i tried
[map(int, [n[1]]) n in a] [[41], [0], [12], [0], [45], [17], [3], [10], [1], [19], [98], [0]] but removes first element. appreciated.
you can as:
a = [['first', '41'], ['second', '0'], ['third', '12']] = [[i[0], int(i[1])]for in a] >>> print [['first', 41], ['second', 0], ['third', 12]]
Comments
Post a Comment