A key in a dictionary cannot have multiple values in Python The above writing is incorrect If you want a key to have multiple values, you must use a list to store the values
dic = {'A1':[12,24,42]}
It is very convenient to calculate the sum in this way, as long as
for key in dic:
dic[key] = sum(dic[key])
print(dic) # {'A1': 78}
The situation mentioned by the poster that the dictionary is in key-value format does not exist at all. A dictionary cannot have duplicate KEYs, and of course each key has only one value
A key in a dictionary cannot have multiple values in Python
The above writing is incorrect
If you want a key to have multiple values, you must use a list to store the values
It is very convenient to calculate the sum in this way, as long as
The situation mentioned by the poster that the dictionary is in key-value format does not exist at all. A dictionary cannot have duplicate KEYs, and of course each key has only one value