I am super new at Python and I am facing a problem when converting a nested list to a list of integer only.
I have this type of nested list in which all sub-list contains strings (digit and char)
lists = [['1', '2', '0', 'a', 'b'], ['3', '2', '1'], ['1','5', '5']]
I want to convert the digits to integer, and also put the char in one list. The output that I want is something like this
`new_lists = [[1, 2, 0, 'a', 'b'], [3, 2, 1], [1, 5, 5]]`
What would i do is something like this
for item in lists: new_list= if (in the first list item can be converted to integer): new_list.append(int(item)) else: new_list.append(item)
How the string can be converted to an integer? Or is there any better way to do it? Thanks in advance