我正在python中使用while循环构建乘法表。虽然数字排列齐整,但输出很奇怪。表格完成情况良好,但看起来很难看。我怎样才能拉直最后三列?我会张贴输出的照片,但我是一个新用户,它不会让我。python乘法表错误
width = int(input("Please enter the width of the table:"))
def print_times_table(width):
row = 0
col = 0
width += 1
spaces = ' '
while row < width:
col = 0
while col < width:
print(row*col, spaces, end="")
col += 1
print("\n", end='')
row +=1
print_times_table(width)
输出:http://i.stack.imgur.com/C9AzE.jpg
如果这是作业,你应该这么说... – Triptych