Categories
Python Answers

How to convert all strings in a list to int with Python?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *