What is the easiest way to convert list with str into list with int in Python? For example, we have to convert [\'1\', \'2\', \'3\']
str
int
[\'1\', \'2\', \'3\']
Python 2.x:
map(int, ["1", "2", "3"])
Python 3.x (in 3.x, map returns an iterator, not a list as in 2.x):
map
list(map(int, ["1", "2", "3"]))
map documentation: 2.6, 3.1