My solution : (i have tested it)
 

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

for i in range(len(list1)-1):
    print list1[i],list1[i+1]  
    list1[i+1] += 1

Note:

# print the consecutive elements; for the first pass of the loop the elements are unchanged, for the remaining we add one.

   



 
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

__________________________________________________
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



--
To HIM you shall return.
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to