Given:

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

Use map then list to obtain a list of integers:

list(map(int, xs))

In Python 2, list was unnecessary since map returned a list:

map(int, xs)
Answer from cheeken on Stack Overflow
Discussions

Converting string in a list to integers
You'll want to rebuild/replace the list. x = [int(n) for n in x] Or, x = list(map(int, x)) If the list is extremely large and you want to do the changes in place, use the index with enumeration. for index, element in enumerate(x): x[index] = int(element) From your post, you never modify x, you simply convert each element to an integer and display them. You never save them back to the original list. More on reddit.com
🌐 r/learnpython
2
1
May 15, 2022
python - converting list of string to list of integer - Stack Overflow
Say there is a list of strings named list_of_strings and output is list of integers named list_of_int. map function is a builtin python function which can be used for this operation. More on stackoverflow.com
🌐 stackoverflow.com
python - How to convert a string list to an int list? - Stack Overflow
I have this list ['456-789-154','741-562-785','457-154-129'] I want to convert it to int list like this: [456,789,154,741,562,785,457,154,129] Please help!! I tried: list = [item.replace("-& More on stackoverflow.com
🌐 stackoverflow.com
December 14, 2020
Convert string list of lists to integer in python - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. I have a dataset in a text file and I read it then split its lines and have created a list of lists like More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-converting-all-strings-in-list-to-integers
Converting all Strings in a List to Integers - Python - GeeksforGeeks
July 11, 2025 - map() function applies a given function to all elements in an iterable. Here, we use map(int, a) to convert each string in the list to an integer. ... List comprehension provides a more Pythonic and concise way to convert a list of strings to ...
🌐
Medium
medium.com › @nawazmohtashim › convert-string-list-to-integer-list-in-python-489a61684496
Convert String List to Integer List in Python | by Mohd Mohtashim Nawaz | Medium
December 11, 2023 - In Python, a list is a versatile data structure that can hold elements of various types, including strings and integers. However, if you have a list of strings representing numerical values and need to perform arithmetic operations or numerical comparisons, it’s crucial to convert those strings to integers.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-integers-string-to-integer-list
Python - Integers String to Integer List - GeeksforGeeks
July 15, 2025 - Using split() and map() will allow us to split a string into individual elements and then apply a function to each element. ... s = "1 2 3 4 5" # Convert the string to a list of integers using split and map int_list = list(map(int, s.split())) ...
🌐
Finxter
blog.finxter.com › how-to-convert-a-string-list-to-an-integer-list-in-python
How to Convert a String List to an Integer List in Python – Be on the Right Side of Change
April 9, 2021 - The most Pythonic way to convert a list of strings to a list of ints is to use the list comprehension [int(x) for x in strings]. It iterates over all elements in the list and converts each list element x to an integer value using the int(x) built-in function.
🌐
PythonForBeginners.com
pythonforbeginners.com › home › convert a list of strings to ints in python
Convert a List of Strings to Ints in Python - PythonForBeginners.com
June 6, 2022 - The list of strings is: ['1', '2', '23', '32', '12', '44', '34', '55', '46', '21', 'Aditya'] Some values in the input list can't be converted to int. The map() function is used to apply a function to all the elements of a container object using a single python statement.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-list-of-numerical-string-to-list-of-integers
Python | Convert list of numerical string to list of Integers - GeeksforGeeks
July 11, 2025 - The list comprehension inside the lambda function iterates through each character of the string and converts it to an integer. This lambda function is then applied to each sublist in the list using the map() function.
🌐
Python Help
pythonhelp.org › tutorials › convert-list-to-int
How to convert a list to int in Python
September 23, 2024 - List comprehension is a concise way to create lists in Python. It can also be used to convert a list to an integer by generating a string representation of the list elements and then converting it to an integer.
🌐
PythonForBeginners.com
pythonforbeginners.com › home › list of strings to list of integers in python
List of Strings to List of Integers in Python - PythonForBeginners.com
April 1, 2022 - We can convert a list of strings to a list of integers using a for loop and the int() function. For this, we will first create an empty list named output_list. After that, we will traverse the list of strings using the for loop. While traversal, we will convert each string element to an integer ...
🌐
Reddit
reddit.com › r/learnpython › converting string in a list to integers
r/learnpython on Reddit: Converting string in a list to integers
May 15, 2022 -

Hi Everyone,

I'm completely new to python and am completing the Python for Everybody specialisation on Coursera. I am trying to convert strings in a list to integers but my code isn't working. I did manage to get it done with list comprehension but was confused as to why this isn't working. My code is below:

x = ['1','2','3','4'] #create list of numbers as strings
for i in x:
    i = int(i) #iterate through each entry in the list and convert it to int from str
print(x)

The output I'm getting from this is still:

['1', '2', '3', '4']

Thanks for all the help!

🌐
YouTube
youtube.com › watch
Python Tips: Converting a string list to an integer list, in 1 line - YouTube
A simple easy way to turn a list of strings into integers in python, all in one line.
Published: March 8, 2021
🌐
LabEx
labex.io › tutorials › python-how-to-convert-a-string-to-a-list-of-integers-in-python-398160
How to convert a string to a list of integers in Python | LabEx
Understanding the basics of strings in Python is crucial for working with text data and performing various text-related operations. Converting a string to a list of integers in Python is a common operation that can be useful in various data processing and manipulation tasks.
🌐
Python Help
pythonhelp.org › python-lists › how-to-convert-list-to-int-in-python
Convert List to Integer in Python
November 21, 2023 - str_list = ["23", "45", ", None, True] int_list = [] for i in str_list: if isinstance(i, int): # Skip if the element is already a number continue elif not isinstance(i, (str, type(None))): # Ignore non-numeric types raise ValueError("Invalid value for conversion to integer: " + str(i)) else: # Convert numeric strings and None to int try: int_list.append(int(i)) except ValueError as e: print("Conversion failed:", str(e)) print(int_list) # Output: [23, 45, None] This will raise a ValueError exception if the element cannot be converted to an integer. Written for working developers, Coding with AI goes beyond hype to show how AI fits into real production workflows. Learn how to integrate AI into Python projects, avoid hallucinations, refactor safely, generate tests and docs, and reclaim hours of development time—using techniques tested in real-world projects.
🌐
Stack Overflow
stackoverflow.com › questions › 65294429 › how-to-convert-a-string-list-to-an-int-list
python - How to convert a string list to an int list? - Stack Overflow
December 14, 2020 - I have this list ['456-789-154','741-562-785','457-154-129'] I want to convert it to int list like this: [456,789,154,741,562,785,457,154,129] Please help!! I tried: list = [item.replace("-&
🌐
TutorialsPoint
tutorialspoint.com › article › converting-all-strings-in-list-to-integers-in-python
Converting all strings in list to integers in Python
The most Pythonic approach uses list comprehension with the int() function to iterate through each element and convert it ? string_numbers = ['5', '2', '-43', '23'] # Given list print("Given list with strings:") print(string_numbers) # Using list comprehension with int() integers = [int(i) for i in string_numbers] # Result print("The converted list with integers:") print(integers)
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python convert list of strings to ints
Python Convert List of Strings to Ints - Spark By {Examples}
3 weeks ago - How to convert a list of strings to ints in Python? You can use list comprehension or the map() function to convert a list of strings to ints in one line
🌐
Statistics Globe
statisticsglobe.com › home › python programming language for statistics & data science › convert list from character string to integer in python (2 examples)
Convert List from Character String to Integer in Python (Example)
May 16, 2023 - As you can see based on the previously shown output of the Python console, our example data is a list object that contains six elements. Let’s check the data type of each item in our list: for i in my_list: print(type(i)) # Return data types of all list elements # <class 'str'> # <class 'str'> # <class 'int'> # <class 'str'> # <class 'int'> # <class 'str'> As you can see, four of the six list elements have the string data type.