[Tutor] multiple assignments when reading a file

Alan Gauld alan.gauld at btinternet.com
Thu Jul 11 10:10:53 CEST 2013


On 11/07/13 04:24, Sivaram Neelakantan wrote:
>
> I'm aware of
>
> var1, var2  = lines.split()
>
> kind of assignments
>
> How do I get to do
>
> x1..xn = lines.split()


x = lines.split()

then you access the fields with x[0], x[1]...x[n]

It's the default behaviour.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list