## layneb131

So im trying to create a times table:
Write a program to print a multiplication table (a times table). At the start, it should ask the user which table to print and how high the table should go.

The output should look something like this:
Which multiplication table would you like?
5
How High?
10

5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50

but my code just keeps running infinitely
(EXAMPLE OF INFINITE OUTPUT)

Which multiplication table would you like:
None7
How high
None9
Heres your table 7 X 9 =
Heres your table 7 X 9 =
Heres your table 7 X 9 =
Heres your table 7 X 9 =
" "

EXAMPLE OF CODE:

``````num1 = int(input(print("Which multiplication table would you like: ")))
num2 = int(input(print("How high")))
total = 1

while total != 0:
total = num1 * num2

print("Heres your table", num1, 'X', num2, '=')``````

## pyTony 888

num1 and num2 do not change inside the while loop so exit condition is never fullfilled.

## layneb131

num1 and num2 do not change inside the while loop so exit condition is never fullfilled.

so how do i get an exit condition. im new to this haha

## woooee 814

Assuming "How high" means the number of rows to print, use a for() loop instead:

``````for ctr in range(num2):
print "row number", num+1``````

A link to getting input from the user. It's for Python 2.x but can be easily modified for 3.x.