I have nested list of the following form:
my_list = [['Some1', '2', '3.6', '4.5', 'GB2', '6'],
['Some2', '3.9', '4', '5', 'HG5', '7.3'],
['Some3', '4', '5', '6.1', 'H2D', '8.9']]
Every element of each sublist is a string, but I'd like to turn all purely numeric strings into floats.
So I try the following code:
for row in my_list:
for k, item in enumerate(row):
if k in (1, 2, 3, 5):
item = float(item)
Unfortunately, the nested list remains unchanged. I'm sure I'm making a simple mistake, but I can't see it. Any help (and context) would be appreciated.