[Tutor] extracting numbers from a list
wesley chun
wescpy at gmail.com
Mon Oct 16 23:37:51 CEST 2006
> I want to print
> 10 15 (first two elements)
> 16 18 (16 is last number +1)
> :
> >>> fx = a[0]
> >>> fy = a[1]
> >>> b = a[2:]
> >>> ai = iter(b)
> >>> last = ai.next()
> >>> for j in ai:
> ... print fy+1,last
> ... last = j
> ...
> 16 18
> 16 20
> 16 25
> 16 30
look very carefully at variables 'fy' vs. 'last', what you do with
them, and when, and you should be able to figure out your homework
assignment problem.
hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com
wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
More information about the Tutor
mailing list