i = 1
j = 1
instr = " "
while i <= 9:
while j <= 9:
instr = instr + str(i) + "*" + str(j) + "=" + str(i*j)
if j == i:
print(instr)
break
j = j + 1
i = i + 1
修改后如下
i = 1
while i <= 9:
j = 1
instr = " "
while j <= 9:
instr = instr + str(i) + "*" + str(j) + "=" + str(i*j)+' '
if j == i:
print(instr)
break
j = j + 1
i = i + 1
break位置写错了,j变化了以后再break