On 01/21/2014 07:18 AM, Adriansanchez wrote:
Hello everyone,
I am newbie to Python and programming in general. My question is, given a list:
X=['washington','adams','jefferson','madison','monroe']
And a string:
Y='washington,adams,jefferson,madison,monroe'

Side note: you can generate X automatically from Y:

X = Y.split(",")
print(X)

split (as name says) splits a string into a list of substrings. The parameter is the separator separating the substrings. In standard (default value), meaning if you don't indicate a separator, python uses any whitespace (space, tab, newline) possibly repeted.

Denis
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to