What is the easiest way to convert list with str into list with int in Python? For example, we have to convert [\'1\', \'2\', \'3\']
str
int
[\'1\', \'2\', \'3\']
If your strings are not only numbers (ie. u''), you can use :
new = [int(i) for i in ["1", "2", "3"] if isinstance(i, int) or isinstance(i, (str, unicode)) and i.isnumeric()]