0

i have a list

strings = ['abc efg hijklmn aaaaa']

and I am trying to split that into a list of multiple strings:

strings = ['abc', 'efg', 'hijklmn', 'aaaaa']

how do I go about doing this? seems very trivial

bob
  • 115
  • 1
  • 2
  • 14
  • 1
    Seriously? Have you ever heard of google? I think 2 minutes search there would have gotten you an answer... – RedX Dec 12 '13 at 07:26
  • possible duplicate of [Split string into a list in Python](http://stackoverflow.com/questions/743806/split-string-into-a-list-in-python) – K DawG Dec 12 '13 at 07:37

3 Answers3

3
strings = ['abc efg hijklmn aaaaa']
strings = strings[0].split()
flyer
  • 8,594
  • 7
  • 41
  • 58
2

This will work even if there are more strings in the original list.

strings = ['abc efg hijklmn aaaaa', 'abc efg hijklmn aaaaa']
print [item for current in strings for item in current.split()]
thefourtheye
  • 221,210
  • 51
  • 432
  • 478
0
otherlist = []
for thing in strings:
    otherlist.extend(thing.split(" "))
strings = otherlist
Alec Teal
  • 5,582
  • 3
  • 19
  • 49