How do I convert all strings in a list to integers?
['1', '2', '3'] ⟶ [1, 2, 3]
Given:
xs = ['1', '2', '3']
Use map
then list
to obtain a list of integers:
list(map(int, xs))
In Python 2, list
was unnecessary since map
returned a list:
map(int, xs)