On 10/16/06, kumar s <[EMAIL PROTECTED]> wrote:
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


  a = [10,15,18,20,25,30, 40]

  print a[0], a[1]

  for i in xrange(2, len(a)):
     print a[i-1] + 1, a[i]

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to