I have a dictionary of numbers, and I would like to get a list of all pairwise multiplications, excluding multiplication with itself.
test_dict = {'id_1': 8, 'id_2': 9, 'id_3': 10}
test_keys = list(test_dict.keys())
list_of_multiples = []
for i in range(0, len(test_keys)):
count = 0
if i == count:
count += 1
else:
if count < len(test_keys):
mult = (test_dict[test_keys[i]] * test_dict[test_keys[count]])
list_of_multiples.append(mult)
count += 1
list_of_multiples
Output: [72, 80]
Intended output: [72, 80, 72, 90, 80, 90]
I'm relatively new so the if logic has been confusing. Also if there is a pre-built function that does this, that would be good too. Thanks a lot