import random
for i in range(100):
a = random.randint(1, 20)
b = random.randint(1, 20)
c = random.randint(1, 20)
if ((a + b + c) % 2) == 0:
print(str(a) + "," + str(b) + "," + str(c))
I tried this but I am not getting the desired output. I want it in a way that three random numbers are chosen between 1 and 20 such that their sum is always even. Here the programme prints only the outputs that are even it does not select the numbers in such a way. Hope you help me. Thanks!
Aucun commentaire:
Enregistrer un commentaire