Re: list/tuple/dict question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: list/tuple/dict question

    bruce wrote:
    so, this still doesn't get me an array called 'cat', or 'dog'
    sure does, in the stuff dictionary:
    >>stuff = {}
    >>foo = []
    >>foo.append('c at')
    >>foo.append('d og')
    >>stuff[foo[1]] = []
    >>stuff
    {'dog': []}

    (note that Python indexing starts with zero, so foo[1] refers to the dog
    entry).
    or do i somehow use stuff to add/extract the vals...???
    >>stuff["dog"]
    []
    >>stuff["dog"].append(1)
    >>stuff["dog"]
    [1]

    etc.

    </F>

Working...