I am trying to loop 2 lots of 'key, value' so I can print 2 lots of data on the same line. However it seems my code prints the output I need, but it is repeating 4 times whereas I need it to only print once. My piece of code:
for key1, value1 in dict1.items():
pct = value1 * 100.0 / s // 1
for key2, value2 in dict2.items():
pct2 = value2 * 20
print(key1, ":", int(pct), "% vs", pct2, "%")
Output:
A : 55 % vs 60 %
A : 55 % vs 20 %
A : 55 % vs 0 %
A : 55 % vs 20 %
B : 25 % vs 60 %
B : 25 % vs 20 %
B : 25 % vs 0 %
B : 25 % vs 20 %
C : 0 % vs 60 %
C : 0 % vs 20 %
C : 0 % vs 0 %
C : 0 % vs 20 %
D : 17 % vs 60 %
D : 17 % vs 20 %
D : 17 % vs 0 %
D : 17 % vs 20 %
But the output I'm needing is:
A : 55 % vs 60 %
B : 25 % vs 20 %
C : 0 % vs 0 %
D : 17 % vs 20 %
I have tried many ways around this, but I cant seem to figure a way to print the output I need.