Kelvin Davis Kelvin Davis - 10 months ago 59
Python Question

String slicing, iterations and list quesiton

Say I have the string "BigJon".

Is there way to iterate through and slice it into two different words like

B igJon
Bi gJon
Big Jo
Bigj on
and so on. And then all these separate pieces be a list?

Answer Source

One liner list comprehension

['%s %s' % (a[:i], a[i:]) for i in range(1, len(a))]