# Python multiplication table and user input

• Comp Sci

## Homework Statement

I'm having and issue with this problem, and I don't understand what I'm doing wrong, I really want to understand the material

Write code that will print a multiplication table for 10 positive integers across the columns and 10 positive integers down the rows. Prompt the user for the starting values for both the columns and the rows.

3. The Attempt at a Solution

Code:
row = int(raw_input("Enter the first row number: "   ))
col = int(raw_input("Enter the first column number: "))

lastRow = row + 10
lastCol = col + 10

while (row < lastRow):
print "%4d" % (col * row)
while(col < lastCol):

print "%4d" % (col * row),
col += 1

print "%4d" % (col * row)
row += 1

I believe my iterations are correct but I don't get the desired print out in grid format, I am unsure as to what the order of the statements should be

Borek
Mentor
What is initial col value when you enter the inner loop for the second time?

I suppose there isn't an initial value for the second loop, what would it need to be?

Borek
Mentor
Draw the table manually (5x5 will be enough) and see what value do you use for calculations.

Mark44
Mentor
Draw the table manually (5x5 will be enough) and see what value do you use for calculations.

In a CS class I took once, the instructor related this adage to us.
The sooner you sit down to the keyboard, the longer it will take to write your program.

That might seem counterintuitive to new programmers, but people who have been writing code for a while realize that putting a reasonable amount of thought into the algorithm beforehand saves a lot of time.

Thanks everyone

Here's my new code which works except I need it to print an outer row and column that shows each value that is multiplied I don't know where to place the print statement for the iterative it keeps messing things up i.e. if entered 1 and 1 it should look like this, and
http://www.mathsisfun.com/tables.html

Code:
row = int(raw_input("Enter the first row number: " ))
col = int(raw_input("Enter the frist column number: "))

lastRow = row + 10
firstCol = col
lastCol = col + 10

while (row < lastRow):

while(col < lastCol):

print "%4d" % (col * row),
col += 1

col = firstCol
row += 1
print