I have a list that looks like this
['111', '222', '333', 'xxx', '3233']
I'd like to change all elements to int
if possible. In this case, xxx
is not a digit. So how can I ignore 'xxx'
and change all other elements to int
?
I can do this with a for loop and some if statements. But I prefer to use map
function if possible. Any other convenient way would be appreciated.