[Tutor] extracting numbers from a list
kumar s
ps_python at yahoo.com
Mon Oct 16 23:18:35 CEST 2006
hi :
I have a simple question to ask tutors:
list A :
a = [10,15,18,20,25,30,40]
I want to print
10 15 (first two elements)
16 18 (16 is last number +1)
19 20
21 25
26 30
31 40
>>> 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
can any one help please.
thank you
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Tutor
mailing list