python - List comprehension for turning a lists of lists of strings into a list of lists of ints and float -
i have list of lists. sublists each contain 3 strings.
bins = [['1', '2', '3.5'], ['4', '5', '6.0']]
i need convert lists of lists each sublist consists of 2 integers , float. thinking of list comprehension along lines of:
[ [int(start), int(stop), float(value)] bn in bins [start, stop, value] in bn]
you're close:
[[int(start), int(stop), float(value)] start, stop, value in bins]
you don't need bn
variable hold each bin or loop iterate through contents; each bin can unpacked directly 3 variables.
Comments
Post a Comment