I need to define a function txtnum(L) that takes a string of comma separated floats such as "1.5,2.5,3.5" as a parameter and converts it into a list [1.5, 2.5, 3.5].
I have tried using .split(), .join(), map(), etc and cannot get anything to return a list that does NOT include quotations. I'm pretty new to Python and a little lost here. 
How would I go about doing this?
You need to convert the datatype of splitted vars because splitting alone string gives you a list of strings.
>>> s = "1.5,2.5,3.5"
>>> [float(i) for i in s.split(',')]
[1.5, 2.5, 3.5]
>>> 
or
>>> map(float, s.split(','))
[1.5, 2.5, 3.5]
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With