Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.109 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.78; '*S*': 0.00; 'odd': 0.07; 'string': 0.09; 'slices': 0.09; 'subject:string': 0.09; '"in"': 0.16; 'between.': 0.16; 'interval,': 0.16; 'numbered': 0.16; 'received:74.208.4.195': 0.16; 'words.': 0.16; 'wrote:': 0.18; 'split': 0.19; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'string,': 0.24; 'header:In-Reply-To:1': 0.27; 'tuples': 0.31; 'but': 0.35; 'there': 0.35; 'like,': 0.36; 'words,': 0.36; 'east': 0.36; 'two': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'space': 0.40; 'even': 0.60; 'letters': 0.60; 'kindly': 0.61; "you're": 0.61; 'email addr:gmail.com': 0.63; 'group,': 0.63; 'our': 0.64; 'zip': 0.64; 'more': 0.64; 'dear': 0.65; 'importantly,': 0.68; 'received:74.208': 0.68; 'divide': 0.84; 'together,': 0.84; 'doubling': 0.91 Date: Sun, 07 Apr 2013 16:46:44 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Splitting of string at an interval References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:u6ER7Ew6+hT4DpDObuPZL2HBM3/8Ap6DLHYswzu5EqR QRXuKBBJsbJ3govDqCWKwuo4mHrabUVRoHrqNqe06PopRrkq/I R8Prsg7zoQ5oMQ125s3xpwA0PuwMALRvsErhY454BXnycrHbUG FzuvgaAx51WxdzZG+YVL7+r3Lv2siNIlE0HZ4okLm2KgVm9B8E Fjh8A+a7ix0PpFya4v2rooGfWhbI68lxjh1ogAqaYxg1xlRvb4 ToMaYXrHUvDuNZ3P83pPRx2EaPXKvpffogvV8DfhffYbFc5m3L b6f4SLD3Us8ThDLUqjwGOFZHDO3qU9DvErH6bz4VNB6WfVg3w= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365367631 news.xs4all.nl 6938 [2001:888:2000:d::a6]:55888 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43021 On 04/07/2013 04:25 PM, subhabangalore@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