[Solved] typerror in python while adding value to keys


If you want to add a a value to key in your dictionary just make sure the values are, from the start, tuples or lists. Once you do this you can just:

    d = {1:(0,),2:(0,)}
    d[1] = d[1]+(0,)

And a new value is now present at d[1]. Other than that and you might have to build a function to handle the difference between types (list, tuple, int, etc).

solved typerror in python while adding value to keys