Skip to content

How to map array of string to int in Python?

The map(int, string_list) maps each string in a list to an integer and returns it.

numbrs = ["10","20","30"]
numbrs = map(int, numbrs)
numbrsList = list(numbrs)
print(numbrsList)
#[10, 20, 30]
See also  Python code snippet - How to append to a list?
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.