[Tutor] How to print certain elements
spir
denis.spir at gmail.com
Tue Jan 21 11:36:43 CET 2014
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
More information about the Tutor
mailing list