I want to write a Multiplication table program. My problem is that the program cannot print to the right side.
The program will ask the user for start and stop. For example:
start_number = 2
stop_number = 4
Output should be like this:
2 x 1 = 2 3 x 1 = 3 4 x 1 = 4
2 x 2 = 4 3 x 2 = 6 4 x 2 = 8
2 x 3 = 6 3 x 3 = 9 4 x 3 = 12
2 x 4 = 8 3 x 4 = 12 4 x 4 = 16
2 x 5 = 10 3 x 5 = 15 4 x 5 = 20
2 x 6 = 12 3 x 6 = 18 4 x 6 = 24
2 x 7 = 14 3 x 7 = 21 4 x 7 = 28
2 x 8 = 16 3 x 8 = 24 4 x 8 = 32
2 x 9 = 18 3 x 9 = 27 4 x 9 = 36
2 x 10 = 20 3 x 10 = 30 4 x 10 = 40
2 x 11 = 22 3 x 11 = 33 4 x 11 = 44
2 x 12 = 24 3 x 12 = 36 4 x 12 = 48
This is my code :
start = int(input("Enter start number : "))
stop = int(input("Enter stop number : "))
def multi_num(start,stop):
for i in range(start, stop+1):
for j in range(1, 13):
print("%d x %d = %d" % (i, j, i * j))
multi_num(start, stop)
This is my output:
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20
2 x 11 = 22
2 x 12 = 24
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30
3 x 11 = 33
3 x 12 = 36
4 x 1 = 4
4 x 2 = 8
4 x 3 = 12
4 x 4 = 16
4 x 5 = 20
4 x 6 = 24
4 x 7 = 28
4 x 8 = 32
4 x 9 = 36
4 x 10 = 40
4 x 11 = 44
4 x 12 = 48
I tried to use end=" "
but it's not working - the program prints output in one line:
2 x 1 = 22 x 2 = 42 x 3 = 62 x 4 = 82 x 5 = 102 x 6 = 122 x 7 = 142 x 8 = 162 x 9 = 182 x 10 = 202 x 11 = 222 x 12 = 243 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 273 x 10 = 303 x 11 = 333 x 12 = 364 x 1 = 44 x 2 = 84 x 3 = 124 x 4 = 164 x 5 = 204 x 6 = 244 x 7 = 284 x 8 = 324 x 9 = 364 x 10 = 404 x 11 = 444 x 12 = 48