I have a list of strings (CD_cent) like this:
2.374 2.559 1.204
and I want to multiply these numbers with a float number. For this I try to convert the list of strings to a list of floats for example with:
CD_cent2=[float(x) for x in CD_cent]
But I always get the error: ValueError: could not convert string to float: '.'. I guess this means, that it can't convert the dot to a float (?!) But how could I fix this? Why doesn't it recognize the dot?
CD_cent == "2.374 2.559 1.204"? If so,for x in CD_centwill iterate over characters, ie,x = 2,x = '.',x = 3, etc. That's why it's complaining, because'.'can't be converted to float.print(CD_cent)gives me'2.374 2.559 1.204'