I have a list say:
[\'batting average\', \'306\', \'ERA\', \'1710\']
How can I convert the intended numbers without touching the strings?>
a= ['batting average', '306', 'ERA', '1710.5'] [f if sum([c.isalpha() for c in f]) else float(f) for f in a ]
if your list contains float, string and int (as pointed about by @d.putto in the comment)