String question

Tim Golden mail at timgolden.me.uk
Mon Jun 23 10:48:47 EDT 2008


Andreu wrote:
> I want to split a sentence and assign each word to a variable.
> In Ruby I can do it as:
> 
> v1,v2,v3,v4,v5 = str1.split
> 
> Which will be the Python equivalent ? Thanks.

That would be:

str1 = "The quick brown fox jumps"
v1, v2, v3, v4, v5 = str1.split ()

TJG



More information about the Python-list mailing list