[Tutor] Fwd: question about lists

Dave Angel davea at davea.name
Wed Dec 4 14:22:30 CET 2013


On Wed, 4 Dec 2013 10:35:46 +0100, Ismar Sehic <i.sheeha at gmail.com> 
wrote:
> so please, i need some pointers in how to get these lists related,
> regarding i cannot use indexing, because i don't always have the 
same
> number of items in list.

First question is whether the data is assumed to be self consistent.  
For example, are you supposed to handle the case where there are a 
different length for the ending dates than for starting dates.?

Once validated,  you can zip two or three lists together and use a 
for loop.

for start, end in zip (starts, ends):

Or if you need a formula you can do something like

For index, value in enumerate (items):
     price = initial + index * increment

Does that help?

-- 
DaveA



More information about the Tutor mailing list