I`ve been trying to convert a string numbers list into float and get the max of this list but I keep getting this error:
ValueError: could not convert string to float: '.'
My attempt was to get a list like ls = ['1','2','3','0.5'] and convert using this function
def convert_to_int(ls: list):
values = [float(a) for a in ls]
return (len(values), values)
print(max(ls, key=convert_to_int))
Why I'm having this error? Can someone help me?
keyshould be a function which applies to individual elements, not to lists of elements. Also -- why are you calling a function designed to covert to floatsconvert_to_int?max(convert_to_int(ls)[1])?