I am trying to write a function that given a number for n it will return individual multiplication tables up to n+1 and the range of each table is also n+1. I have got the code write to get what I am looking for but I don't know how to make separate tables, my teacher has a gift for asking for things in the homework that aren't in the lecture.
[IN]:
n = 4
def multitables(n):
for i in range(1, n+1):
for j in range(1, n+1):
print ('{0} {1} {2}'.format(i, j, i*j))
print(multitables(n))
[OUT]:
1 1 1
1 2 2
1 3 3
1 4 4
1 5 5
2 1 2
2 2 4
2 3 6
2 4 8
3 1 3
3 2 6
3 3 9
3 4 12
4 1 4
4 2 8
4 3 12
4 4 16
How do I get it to make multiple tables side by side for each iteration of i So instead I would have:
[IN]:print(multitable(4))
[OUT]:
1 1 1 2 1 2 3 1 3 4 1 4
1 2 2 2 2 4 3 2 6 4 2 8
1 3 3 2 3 6 3 3 9 4 3 12
1 4 4 2 4 8 3 4 12 4 4 16
Thank you