How to split value where is comma ?

John Gordon gordon at panix.com
Thu Sep 8 10:57:04 EDT 2016


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)

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon at panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"




More information about the Python-list mailing list