[Tutor] results not quite 100 percent yet

bhaaluu bhaaluu at gmail.com
Wed Jan 30 13:29:22 CET 2008

On Jan 29, 2008 9:26 PM, Kent Johnson <kent37 at tds.net> wrote:
> bhaaluu wrote:
> >     if keY == 6 or keY == 11 or tablE.values()[keY-1][6] != 0:
> >         tablE.values()[5][6] = 0
> >         tablE.values()[10][6] = 0
> This is not the right way to access the values of a dict. tablE.values()
> is a list of the values in tablE, but it is not in the order you expect;
> it is easiest to think that it is in a random or indeterminate order.
> Try
>      if keY == 6 or keY == 11 or tablE[keY-1][6] != 0:
>          tablE[5][6] = 0
>          tablE[10][6] = 0
> etc.
> Kent

Now that you mention it, I do seem to remember that the order of
a list is indeterminate.

What kind of Python array structure would you use if you need to
access each element in the exact order it appears in the table?
The only element that gets changed is the last one, all the others
stay exactly the same. So far, this structure seems to be working
okay in the big program. Maybe 2-3% of the time is an integer put
in keys 6 or 11.

b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance.  Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]

More information about the Tutor mailing list