On Sun, Jan 11, 2015 at 6:12 PM, Thomas 'PointedEars' Lahn <pointede...@web.de> wrote: > Joel Goldstick wrote: > >> Thomas 'PointedEars' Lahn wrote: >>> Joel Goldstick wrote: >>>> my_list = "1.23, 2.4, 3.123".split(",") >>>> >>>> that will give you ['1.23', '2.4', '3.123'] >>> >>> No, it gives >>> >>> […] >>> | >>> my_list = "1.23, 2.4, 3.123".split(",") >>> | >>> my_list >>> | ['1.23', ' 2.4', ' 3.123'] > ^ ^ >>> | >>> >>> >>> In order to get the result you described, one needs at least >>> >>> | >>> '1.23, 2.4, 3.123'.split(', ') >>> | ['1.23', '2.4', '3.123'] >>> >>> […] >> >> I'm not sure what you are trying to point out as your examples confirm >> my code. > > No, they don't. > >> Am I missing something. > ^ > (Is that a question.) > > You are missing a leading space character because in the string the comma > was followed by one.
I see that now. Performing float on each element of the list will take care of that, or I guess .strip() on each first. > >> As for feeding a beginner regex solutions, I'm on the side that this >> is a terrible idea. Regex is not something a beginner should worry >> about! > > NAK. > > -- > PointedEars > > Twitter: @PointedEars2 > Please do not cc me. / Bitte keine Kopien per E-Mail. > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list