Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43021
| Date | 2013-04-07 16:46 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: Splitting of string at an interval |
| References | <e66efa13-c35d-4169-b3cc-3617d3d6a8c7@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.256.1365367631.3114.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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