我不需要答案,如果可能的话,只需要一个起点。
我已经做了一个可以打印1-10的乘法表,但我的教授希望看到这个表存储在2D列表中。我有我当前的代码(工作代码,在这里张贴),以及我专门为"2D列表“版本制作的新代码,但我在这两个版本上都一无所获。
EDIT:我可能应该澄清一下,代码正在做我想要它做的事情,那就是输出一个乘法表,但我在将它转换为2D列表时遇到了麻烦。
#Initial list and global variables
MT = ["X", 1, 2, 3, 4, 5, 6, 7, 8, 9 ,10]
mult = 1
jump = 0
repeat = 1
list = 1
while repeat < 12:
index = 1
mult = 1
jump += 1
MT.append(MT[list])
while (index < 11):
MT.append(mult * jump)
mult += 1
index += 1
else:
repeat += 1
list += 1
else:
print("Multiplication Table:")
index = 0
while (index < 121):
if (((index + 1) % 11) != 0):
print(MT[index], end = "\t")
else:
print(MT[index], end = "\n")
index += 1
https://stackoverflow.com/questions/51460055
复制相似问题