[Tutor] results not quite 100 percent yet
Kent Johnson
kent37 at tds.net
Wed Jan 30 14:24:52 CET 2008
bhaaluu wrote:
> Now that you mention it, I do seem to remember that the order of
> a list is indeterminate.
No; the order of a dict is indeterminate, and consequently the order of
lists derived from dicts with keys(), values(), etc. is indeterminate.
The order of a list is determined by how you create it.
>
> 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?
A list of lists may be the correct structure for your program. You could
define tablE as
tablE= [[ 0, 2, 0, 0, 0, 0, 0], # 1
[ 1, 3, 3, 0, 0, 0, 0], # 2
[ 2, 0, 5, 2, 0, 0, 0], # 3
...
[ 9, 0, 0,16, 0, 0, 0]] # 19
Kent
More information about the Tutor
mailing list