I have a list of strings in the form like
a = ['str','5','','4.1']
I want to convert all numbers in the list to float, but leave the rest unchanged, like this
a = ['str',5,'',4.1]
I tried
map(float,a)
but apparently it gave me an error because some string cannot be converted to float. I also tried
a[:] = [float(x) for x in a if x.isdigit()]
but it only gives me
[5]
so the float number and all other strings are lost. What should I do to keep the string and number at the same time?