[Tutor] extracting numbers from a list

Kent Johnson kent37 at tds.net
Tue Oct 17 03:00:47 CEST 2006


Asrarahmed Kadri wrote:
> 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 that this changes the original list, which may or may not be 
acceptable. Normally you would expect a printing function not to change 
the value being printed.

Kent



More information about the Tutor mailing list