Split string into different variables instead of array in Python

Question:

Possible Duplicate:
Python Split String

Is possible to directly split string into variables in one line, instead of using two lines. I’m sure that split would have two elements.
Two lines example:

myString = "Anonym Anonymous"
a = myString.split()
firstName,lastName = a[0],a[1]
Asked By: kravemir

||

Answers:

firstname, lastname = "Anonym Anonymous".split()
Answered By: Christopher Bruns

firstName, lastName = myString.split() should do it if you’re sure it will return 2.

Better is firstName, lastName = myString.split(' ', 1)

Answered By: TorelTwiddler
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.