In Python, I want to convert a list of strings:
l = [\'sam\',\'1\',\'dad\',\'21\']
and convert the integers to integer types like this:
Use isdigit() to check each character in the string to see if it is a digit.
Example:
mylist = ['foo', '3', 'bar', '9'] t = [ int(item) if item.isdigit() else item for item in mylist ] print(t)