Store more than 1 value in python array?
Question: I would like to store more than 1 value in a python array(I am open to any
other data structure too).

For example :

    
    
    array[1][2][3] = 1  # (this is what I am able to do now)
    

But later I also get the value 2, now instead of storing it in another array
using the same indices, I want to be able to do this :

    
    
    array[1][2][3] = 1,2 
    

But I dont want to concatenate the existing result like in a string, and split
the string to get the individual values.

Is there a way of doing this without having to introduce another dimension to
the array?

edit : I want a neater way to store 2 values in the same cell.

Thanks


Answer: I would use defaultdict for this:

    
    
    from collections import defaultdict
    array = defaultdict(list)
    array[(1,2,3)].append(1)
    array[(1,2,3)].append(2)
    

Now array at position (1,2,3) is a list containing 1 and 2

