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
  • 135
  • 1
  • 4
  • 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
  • 9,280
  • 11
  • 46
  • 62
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
  • 233,700
  • 52
  • 457
  • 497
0
otherlist = []
for thing in strings:
    otherlist.extend(thing.split(" "))
strings = otherlist
Alec Teal
  • 5,770
  • 3
  • 23
  • 50