Intellipaat Back

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

Let's say, I have:

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

How can I change it to:

results = [1, 2, 3]

1 Answer

0 votes
by (26.4k points)

In the case of Python 2.x, we can use the map function

results = map(int, results)

In the case of Python 3, You actually need to convert the result from map into a list:

results = list(map(int, results))

Want to know more about python? Come and Join: Python training course

Related questions

0 votes
1 answer
0 votes
1 answer
asked Aug 6, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...