Kelvin Davis Kelvin Davis - 4 months ago 34
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?


One liner list comprehension

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