Hey,
I was wondering if someone could help to figure out , how to add a value to a key that already exists in the dictionary.
where the values of each key are lists.

so for example:

theIndex = {124:["b","s"], 356:["dg", "n"]}
and i want to add the value "m" to the values of the key 124.


thanks!

theIndex[124] is a list, so you can just write

theIndex[124].append("m")

Alright! thanks a lot. that works :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.