[Tutor] Multiple Dimension (array/list/whatever it is are).
Thomas Clive Richards
thomi at imail.net.nz
Mon May 10 05:09:51 EDT 2004
On Monday 10 May 2004 20:33, George Patterson wrote:
> 1. What is the data structure below called? Apart from G :-P Is it an
> array, a list or something else. The original article was very vague on the
> commenting. See bottom of email for URL.
>
> G = {'s':{'u':10, 'x':1},
> 'u':{'v':1, 'x':2},
> 'v':{'y':4},
> 'x':{'u':3, 'v':9, 'y':2},
> 'y':{'s':7, 'v':6}
> }
>
This is a dictionary....containing other dictionaries. They're used to provide
key->value mappings.
>
> 2. How would I alter the above data structure such that all instances of
> 'x' ends up being equal to 5. As per sample below.
>
> {'s':{'u':10, 'x':5},
> 'u':{'v':1, 'x':5},
> 'v':{'y':4},
> 'x':{'u':3, 'v':9, 'y':2},
> 'y':{'s':7, 'v':6}
> }
>
not sure what you mean here.. doing "G['x']" would return "{'u':3, 'v':9,
'y':2}". i.e.- another dictionary, not a numeric value...
HTH
--
Thomi Richards,
thomi at once.net.nz
More information about the Tutor
mailing list