Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43021

Re: Splitting of string at an interval

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 <davea@davea.name>
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 <davea@davea.name>
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 <e66efa13-c35d-4169-b3cc-3617d3d6a8c7@googlegroups.com>
In-Reply-To <e66efa13-c35d-4169-b3cc-3617d3d6a8c7@googlegroups.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.256.1365367631.3114.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Splitting of string at an interval subhabangalore@gmail.com - 2013-04-07 13:25 -0700
  Re: Splitting of string at an interval Dave Angel <davea@davea.name> - 2013-04-07 16:46 -0400
  Re: Splitting of string at an interval Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-07 21:48 +0000
    Re: Splitting of string at an interval Chris Angelico <rosuav@gmail.com> - 2013-04-08 13:01 +1000
      Re: Splitting of string at an interval Roy Smith <roy@panix.com> - 2013-04-08 09:21 -0400
        Re: Splitting of string at an interval Arnaud Delobelle <arnodel@gmail.com> - 2013-04-08 16:10 +0100
        Re: Splitting of string at an interval Roy Smith <roy@panix.com> - 2013-04-08 11:37 -0400
        Re: Splitting of string at an interval Chris Angelico <rosuav@gmail.com> - 2013-04-09 02:20 +1000
        Re: Splitting of string at an interval Arnaud Delobelle <arnodel@gmail.com> - 2013-04-08 17:30 +0100
          Re: Splitting of string at an interval Roy Smith <roy@panix.com> - 2013-04-08 21:09 -0400
            Re: Splitting of string at an interval Tim Chase <python.list@tim.thechases.com> - 2013-04-08 20:42 -0500
            Re: Splitting of string at an interval Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-09 02:38 +0000
              Re: Splitting of string at an interval Andrew Berg <bahamutzero8825@gmail.com> - 2013-04-08 21:57 -0500
              Re: Splitting of string at an interval Chris Angelico <rosuav@gmail.com> - 2013-04-09 14:22 +1000
              Re: Splitting of string at an interval Dave Angel <davea@davea.name> - 2013-04-09 02:28 -0400
        Re: Splitting of string at an interval Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-04-08 19:15 -0400

csiph-web