In article <46a5e979-7a87-49ee-ac7e-71d3a235d...@e37g2000yqn.googlegroups.com>,
joy99 wrote:
>
>input_string=raw_input("PRINT A STRING:")
>string_to_word=input_string.split()
>len_word_list=len(string_to_word)
>if len_word_list>9:
> rest_words=string_to_word[9:]
> len_rest
On Tue, 29 Dec 2009 01:35:41 -0500, Steven D'Aprano
wrote:
On Tue, 29 Dec 2009 00:49:50 -0500, John Posner wrote:
On Sun, 27 Dec 2009 09:44:17 -0500, joy99
wrote:
Dear Group,
I am encountering a small question.
Suppose, I write the following code,
input_string=raw_input("PRINT A STRING:
On Tue, 29 Dec 2009 01:35:41 -0500, Steven D'Aprano
wrote:
On Tue, 29 Dec 2009 00:49:50 -0500, John Posner wrote:
On Sun, 27 Dec 2009 09:44:17 -0500, joy99
wrote:
Dear Group,
I am encountering a small question.
Suppose, I write the following code,
input_string=raw_input("PRINT A STRING:
On Tue, 29 Dec 2009 01:35:41 -0500, Steven D'Aprano
wrote:
On Tue, 29 Dec 2009 00:49:50 -0500, John Posner wrote:
On Sun, 27 Dec 2009 09:44:17 -0500, joy99
wrote:
Dear Group,
I am encountering a small question.
Suppose, I write the following code,
input_string=raw_input("PRINT A STRIN
On Tue, 29 Dec 2009 00:49:50 -0500, John Posner wrote:
> On Sun, 27 Dec 2009 09:44:17 -0500, joy99
> wrote:
>
>> Dear Group,
>>
>> I am encountering a small question.
>>
>> Suppose, I write the following code,
>>
>> input_string=raw_input("PRINT A STRING:")
>> string_to_word=input_string.split()
"John Posner" writes:
> I haven't found a generator version of the string function split(). Am
> I missing something?
To my knowledge there isn't one. Both Python 2 and Python 3 document
‘str.split’ as returning a list.
--
\ “An idea isn't responsible for the people who believe in it.”
On Sun, 27 Dec 2009 09:44:17 -0500, joy99
wrote:
Dear Group,
I am encountering a small question.
Suppose, I write the following code,
input_string=raw_input("PRINT A STRING:")
string_to_word=input_string.split()
len_word_list=len(string_to_word)
if len_word_list>9:
rest_words=
Lie Ryan wrote:
> On 12/28/2009 8:54 PM, Peter Otten wrote:
>> Francesco Bochicchio wrote:
>> One with lazy chunks:
>>
> from itertools import chain, islice
> def chunks(items, n):
>> items = iter(items)
>> for first in items:
>> yield chain((first,), isl
On Dec 28, 5:28 pm, Vlastimil Brom wrote:
> 2009/12/27 joy99 :
>
> > Dear Group,
> > Answers were good. But I am looking for a smarter solution like:
>
> > for i[:2] in list:
> >
>
> > etc. or by doing some looping over loop.
> > Do not worry I'll work out the answer.
>
> > Wishing you a happ
On 12/28/2009 8:54 PM, Peter Otten wrote:
Francesco Bochicchio wrote:
One with lazy chunks:
from itertools import chain, islice
def chunks(items, n):
items = iter(items)
for first in items:
yield chain((first,), islice(items, n-1))
[list(chunk) for chun
2009/12/27 joy99 :
> Dear Group,
> Answers were good. But I am looking for a smarter solution like:
>
> for i[:2] in list:
>
>
> etc. or by doing some looping over loop.
> Do not worry I'll work out the answer.
>
> Wishing you a happy day ahead,
> Regards,
> Subhabrata.
> --
> http://mail.pyt
Francesco Bochicchio wrote:
> Not sure I understood your question, but if you need just to plit a
> big list in sublists of no more than 9 elements, then you can do
> someting like:
>
> def sublists(biglist, n ):
> "Splits a big list in sublists of max n elements"
> prev_idx = 0;
On 27 Dic, 22:29, joy99 wrote:
> On Dec 27, 8:42 pm, Benjamin Kaplan wrote:
>
>
>
> > On Sun, Dec 27, 2009 at 9:44 AM, joy99 wrote:
> > > Dear Group,
>
> > > I am encountering a small question.
>
> > > Suppose, I write the following code,
>
> > > input_string=raw_input("PRINT A STRING:")
> > > s
On Dec 27, 8:42 pm, Benjamin Kaplan wrote:
> On Sun, Dec 27, 2009 at 9:44 AM, joy99 wrote:
> > Dear Group,
>
> > I am encountering a small question.
>
> > Suppose, I write the following code,
>
> > input_string=raw_input("PRINT A STRING:")
> > string_to_word=input_string.split()
> > len_word_list
On Sun, Dec 27, 2009 at 9:44 AM, joy99 wrote:
> Dear Group,
>
> I am encountering a small question.
>
> Suppose, I write the following code,
>
> input_string=raw_input("PRINT A STRING:")
> string_to_word=input_string.split()
> len_word_list=len(string_to_word)
> if len_word_list>9:
> r
A couple of notes:
Your code is too packed together. That makes it hard to read. Put in some
whitespace (and comments, where necessary), and put spaces around your equal
signs (x = 23 instead of x=23).
That said, here's something I threw together:
#!/usr/bin/env python
def chop_list(words, si
Dear Group,
I am encountering a small question.
Suppose, I write the following code,
input_string=raw_input("PRINT A STRING:")
string_to_word=input_string.split()
len_word_list=len(string_to_word)
if len_word_list>9:
rest_words=string_to_word[9:]
len_rest_word=len(rest_
17 matches
Mail list logo