Sometimes, we want to convert all strings in a list to int with Python.
In this article, we’ll look at how to convert all strings in a list to int with Python.
How to convert all strings in a list to int with Python?
To convert all strings in a list to int with Python, we can use the map
function.
For instance, we write
results = list(map(int, results))
to map all the values in the results
list to ints with int
.
And then we convert the map back to a list with list
.
Conclusion
To convert all strings in a list to int with Python, we can use the map
function.