Author -  Sai gowtham

How to convert all strings in a list to ints in Python

In this tutorial, we are going to learn about how to convert all strings in a list to integers in Python.

Consider, we have a following prices list:

prices = ['2', '3', '4']

Now, we need to convert the above list of strings to a list of integers like this:

[2, 3, 4]

Converting list of strings to integers

To convert the list of strings to integers, we can use the built-in map() function in Python.

Here is an example:

prices = ['2', '3', '4']
int_map = map(int, prices)
int_list = list(int_map)

print(int_list)

Output:

[2, 3, 4]

In the code above, the map() function applies the int() to each iterable in the list and converts it to ints, then we have passed the map() output to list() function to convert it to a list.

Similarly, we can also do it by using a list comprehension syntax in Python.

prices = ['2', '3', '4']
int_list = [int(el) for el in prices]

print(int_list)

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY