<html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><META name="Author" content="Novell GroupWise WebAccess"></head><body style='font-family: Tahoma, sans-serif; font-size: 13px; '>Hi,<br>I want to be able to add multiple new values to a key in a dictionary.<br><br>I have tried the following:<br><br>sec_dict_clean=<br>{88: [87, 89, 78, 98], 58: [57, 59, 48, 68], 69: [79], 95: [94, 96, 85]}<br><br>for i in range(len(sec_dict_clean.values())):<br>    for j in range(len(sec_dict_clean.values()[i])):<br>        sec_dict_clean.setdefault(key,[]).append(blocks[sec_dict_clean.values()[i][j]].abundance)<br><br>where blocks[...].abundance gives me a single value from an object,<br><br>but this gives me the following:<br><br>sec_dict_clean=<br>{88: [87, 89, 78, 98], 58: [57, 59, 48, 68], 69: [79], 95: [94, 96, 85, 4, 12, 11, 6, 9, 12, 11, 7, 10, 10, 12, 9, 6, 12, 15, 9, 8, 12, 15, 12, 12]}<br><br>instead I want each abundance (starts with 4, 12...) to be associated with each of the values so that it would look like this:<br><br>sec_dict_clean=<br>{88: ([87, 89, 78, 98], [4,12,11,6]), 58: ([57, 59, 48, 68], [9,12,11,7]), 69: ([79], [10])...}<br><br>You can see there are several errors here (I have more things being appended than there are values in the dictionary), but I really just want to know how to add multiple values to the same key in a dictionary.<br><br>Thanks for any help,<br>Krishna<br>
<br></body></html>