Michael Michael - 8 months ago 71
Python Question

Convert all strings in a list to int

Possible Duplicate:

How to convert strings into integers in python?

How to convert a string list into an integer in python

In python, I want to convert all strings in a list to ints.

So if I have:

results = ['1', '2', '3']

How do I make it:

results = [1, 2, 3]


Use the map function(in py2):

results = map(int, results)

In py3:

results = list(map(int, results))