0
for i in range(1,6):
    for j in range(1,6):
        print(i*j,end ='\t')
    print(' ')
#creates a 5x5 table

I've created a 5x5 multiplication square table but I don't know how to adapt this so that when an even number is found, 0 is printed within the table. I understand that the remainder of and i and j must be zero in order for it to be even.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • Does this answer your question? [Find the division remainder of a number](https://stackoverflow.com/questions/5584586/find-the-division-remainder-of-a-number) – wjandrea Oct 07 '21 at 20:56

1 Answers1

3

Use modulus, i.e.

print(i*j if i*j%2==1 else 0,end='\t')
M. Chak
  • 530
  • 3
  • 13