[Tutor] a list of tuples with varying lengths

Phil phillor9 at gmail.com
Wed Jan 19 01:20:50 EST 2022


I hope the following makes sense to you and I'm not sure that I should 
even post such a vague question.

What I need is s, d to = (0, 4) during the first time interval and then 
s, d = (0, 3) and (1, 4) the second time. There are many time intervals, 
this is just the first two.

My solution is to have a look_up table that looks something like this, 
the first three entries are:

table = [[(0, 4)], [(0, 3), (1, 4)], [(0, 2), (1, 3), (2, 4)]]

The first entry has 1 tuple the second entry has 2 tuples the third has 
3 tuples, etc

My first thought was to extract the tuple values with a for-loop with a 
variable range, like this: for s, d in range(len(table[index])) but that 
idea ended in failure. I cannot see a simple way to calculate the values 
even though there is a pattern and so a look-up table seems like a good 
idea.

I've spent days on this and have made little progress so any ideas will 
be greatly appreciated.

-- 

Regards,
Phil



More information about the Tutor mailing list