Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

string to list

>>> names='''
...       Apple
...       Ball
...       Cat'''
>>> names
'
      Apple
      Ball
      Cat'
>>> names_list = [y for y in (x.strip() for x in names.splitlines()) if y]
>>> # if x.strip() is used to remove empty lines
>>> names_list
['Apple', 'Ball', 'Cat']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #string #list
ADD COMMENT
Topic
Name
9+6 =