0 votes
1 view
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
0 votes
1 answer
0 votes
1 answer
asked Aug 6, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...