我有這個問題---Python中的乘法表
編寫代碼將打印10個正整數的乘積表和10個正整數下行。提示用戶輸入列和行的起始值。
我試圖從另一個問題,不打印像Id期望它的一些解釋。我在哪裏調用print語句,什麼是錯的迭代
row = int(raw_input("Enter the first row number: " ))
col = int(raw_input("Enter the frist 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
這裏有一個二去,更好,但並不像我想得
row = int(raw_input("Enter the first row number: " ))
col = int(raw_input("Enter the frist column number: "))
lastRow = row + 10
lastCol = col + 10
x=row
y=col
while (x < lastRow):
while(y < lastCol):
y += 1
print "%4d" % (y * x)
x += 1
很抱歉的重複後,我沒有知道這是不好的禮節
[Python用戶輸入和乘法表]的可能重複(http://stackoverflow.com/questions/7990991/python-user-input-and-multiplication-table) – agf