Skip to content

String to list of ints

Ariel Balter edited this page Apr 8, 2016 · 1 revision
a = "1, 2, 3, 4"
b = [int(x) for x in a.split(",")]

Works in python2 or python3

https://stackoverflow.com/questions/7368789/convert-all-strings-in-a-list-to-int/7368914#7368914

Clone this wiki locally