On 04/07/2013 04:25 PM, subhabangal...@gmail.com wrote:
Dear Group,

I was looking to split a string in a particular interval, like,

If I have a string,
string="The Sun rises in the east of  our earth"

Are you asserting that there is nothing but letters and whitespace in the string, and that any amount of consecutive whitespace may be considered a blank?


I like to see it as,
words=["The Sun","rises in","in the","east of","our earth"]

Those aren't words, they're phrases. But more importantly, you're somehow doubling the word "in" before parsing.


If any one of the learned members can kindly suggest.


split it into a list, use slices to divide that into even and odd numbered words. Use zip to combine those two list together, and then combine the resultant tuples with a space between.


--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to