I’m trying to write a function that does something like this:
>>> Give-me the name of three famous American (use a comma to separate the names).
Benjamin Franklin, Thomas Jefferson, Carl Sagan
And put the given names into a list like this: [“Benjamin Franklin”, “Thomas Jefferson”, “Carl Sagan”] and NOT a list like this: [‘Benjamin’, ‘Franklin,’, ‘Thomas’, ‘Jefferson,’, ‘Carl’, ‘Sagan’] as the split() method does.
There are (in Python 2.6) some method or function that can recognize the comma to form lists elements?
The
splitmethod of the string also takes a separator as an optional argument.