Re: [Tutor] confusing enumerate behavior

2009-02-06 Thread عماد نوفل
On Fri, Feb 6, 2009 at 6:54 AM, Kent Johnson wrote: > 2009/2/6 jitendra gupta : > > > Try this if u r looking for this kind of solution > my_input = "one two three four five six seven eight nine ten" > text = my_input.split() > for i in range(len(text)): > >if i+3>=len(text):

Re: [Tutor] confusing enumerate behavior

2009-02-06 Thread Kent Johnson
2009/2/6 jitendra gupta : > Try this if u r looking for this kind of solution my_input = "one two three four five six seven eight nine ten" text = my_input.split() for i in range(len(text)): >if i+3>=len(text): >print text[i-3:len(text):1] >elif i<=2: >

Re: [Tutor] confusing enumerate behavior

2009-02-06 Thread spir
Le Fri, 6 Feb 2009 12:30:31 +0530, jitendra gupta a écrit : > > #BEGIN > > my_input = "one two three four five six seven eight nine ten" > > text = my_input.split() > > for i,v in enumerate(text): > > line = text[i-3], text[i-2], text[i-1], v, text[i+1], text[i+2], > > text[i+3] > > prin

Re: [Tutor] confusing enumerate behavior

2009-02-05 Thread jitendra gupta
On Fri, Feb 6, 2009 at 5:43 AM, Emad Nawfal (عماد نوفل) wrote: > Hi Tutors, > I'm a little, actually a lot confused by the behavior of the enumerate > function here. I have a text and I want to get each word within the context > of the three preceding and the three following words. I tried this:

Re: [Tutor] confusing enumerate behavior

2009-02-05 Thread Alan Gauld
"Emad Nawfal (عماد نوفل)" wrote I'm a little, actually a lot confused by the behavior of the enumerate Its not enumerate thats confusing you its indexing. my_input = "one two three four five six seven eight nine ten" text = my_input.split() for i,v in enumerate(text): line = text[i-3],

[Tutor] confusing enumerate behavior

2009-02-05 Thread عماد نوفل
Hi Tutors, I'm a little, actually a lot confused by the behavior of the enumerate function here. I have a text and I want to get each word within the context of the three preceding and the three following words. I tried this: #BEGIN my_input = "one two three four five six seven eight nine ten" tex