>>> pairs {('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
such as here ('66', '69') and ('69', '66') is one key, I wanna keep only one and add the value of those two keys, above is a very simple example: here is the (failed) code: for k, v in pairs.items(): if str(k)[1]+str(k)[0] in pairs.keys(): print(pairs[str(k)[1]+str(k)[0]]) pairs[k]+=pairs[str(k)[1]+str(k)[0]] del pairs[str(k)[1]+str(k)[0]] print(v,k) Thanks for any advice, _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor