How to split value where is comma ?

Larry Hudson orgnut at yahoo.com
Thu Sep 8 16:05:59 EDT 2016


On 09/08/2016 07:57 AM, John Gordon wrote:
> In <mailman.39.1473302345.2411.python-list at python.org> Joaquin Alzola <Joaquin.Alzola at lebara.com> writes:
>
>> Use the split
>
>> a.split(",")
>> for x in a:
>> print(x)
>
> This won't work.  split() returns a list of split elements but the
> original string remains unchanged.
>
> You want something like this instead:
>
>     newlist = a.split(",")
>     for x in newlist:
>         print(x)
>

Even easier...

for x in a.split(','):
     print(x)

-- 
      -=- Larry -=-



More information about the Python-list mailing list