Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (1.6k points)

In Python, I want to convert all strings in a list to integers.

So if I have:

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

How do I make it:

results = [1, 2, 3]

1 Answer

0 votes
by (25.1k points)

You can use simple list comprehension, like this:

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

results = [int(x) for x in results]

print(results)

Related questions

0 votes
1 answer
asked Dec 3, 2020 in Python by laddulakshana (16.4k points)
0 votes
1 answer
0 votes
1 answer
asked Aug 6, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer

Browse Categories

...