On Jun 24, 5:38 am, "Mark Tolonen" <[EMAIL PROTECTED]> wrote: > "Andreu" <[EMAIL PROTECTED]> wrote in messagenews:[EMAIL PROTECTED] > > Yes, ... don't ask me why, but in fact v1,v2,v3 = str1.split() > > does not seem to work. My original problem was I forgot about > > the parenthesis as Tim point out. So I ended up converting to a > > list as in: v = str1.split() and accessing the elements using > > v[0] v[1] ect...it is working now. Thanks. > > > Andreu. > > v1,v2,v3 = str1.split() will only work if there are exactly three things in > str1. > > >>> s = 'this is a test' > >>> v1,v2,v3 = s.split() > > Traceback (most recent call last): > File "<interactive input>", line 1, in <module> > ValueError: too many values to unpack>>> v1,v2,v3 = s.split(' ',2) # limit > to two splits maximum > >>> v1 > 'this' > >>> v2 > 'is' > >>> v3 > > 'a test' > > -Mark
In Python 3k I believe you can put a * next to one of the variables to hold multiple arguments. That'll be aidful! -- http://mail.python.org/mailman/listinfo/python-list