iMohammad
iMohammad

Reputation: 83

How to convert str to int in Python list

I have a list:

a = ['1','2','4','3','7','5']

I want to convert str to int.

In fact, I want to write a function that multiplies a number in the list elements.

Upvotes: 0

Views: 779

Answers (1)

James Fulton
James Fulton

Reputation: 332

To turn a string to an integer you can just use the built-in int(x) function (see documentation).

To do it to your whole list try:

[int(x) for x in a]

Upvotes: 2

Related Questions