Problems retrieving items from a list using a reference rather than an integer - can you help?

Bengt Richter bokr at oz.net
Thu Jul 17 01:56:29 EDT 2003


On Wed, 16 Jul 2003 22:57:16 +0100, "Rogue9" <lol at lolmc.com> wrote:

>Hi,
>I´m trying to retrieve an item from a list using a reference called
>´draw´' (which is an integer from 1 to 792 in a while loop) using:-
>
>draw = 1
>while 1:
>	if draw == 792:
>		break
>	b1 = someOtherList[draw-1]
>	r1 = b1[draw]
>	draw = draw+1
>
>However,the item I expect is not being retrieved i.e. a zero is the result
>of the retrieval rather than the integer in the list I was expecting.
>Furthermore,when I substitute an integer for draw e.g. r1 = b1[12],I
>do get the expected result.
>Can anyone enlighten me as to why and how to get over this please?
Assuming all the lists are big enough, why is not the end result of the
above loop just
     b1 = someOtherList[790]
     r1 = b1[791]
     draw = 792
In other words, you are not showing how your code showed you what was "being retrieved."
Put in some prints to show us. Unless there are some sneaky side effects, you could as
well start draw off at e.g. 789 so there won't be too much printing ;-)
Is someOtherList a big list of lists or is it some strange indexable producing another
strange indexable when indexed?

Regards,
Bengt Richter




More information about the Python-list mailing list