How to iterate the input over a particular size?
benjamin.kaplan at case.edu
Sun Dec 27 16:42:41 CET 2009
On Sun, Dec 27, 2009 at 9:44 AM, joy99 <subhakolkata1234 at gmail.com> wrote:
> Dear Group,
> I am encountering a small question.
> Suppose, I write the following code,
> input_string=raw_input("PRINT A STRING:")
> if len_word_list>9:
> if len_rest_word>9:
> In this program, I am trying to extract first 9 words from an
> indefinitely long string, until it reaches 0.
> Am I writing it ok, or should I use while, or lambda?
> If any one can suggest.
> Hope you are enjoying a nice vacation of Merry Christmas. If any one
> is bit free and may guide me up bit.
> Wishing you a happy day ahead,
> Best Regards,
You want the first 9 words? string_to_word[:9]
You want the last 9 words? string_to_word[-9:]
If you want the groups of words, use a loop- that's the only way to
get all of them for any length list.
More information about the Python-list