Use the for loop to print out the nine-nine multiplication table in python

Use the python language to print out a nine-nine multiplication table, combined with the for loop statement, output nine rows and nine columns, pay attention to alignment.

# 通过外层循环控制行数
for i in range(1, 10):
    # 通过内层循环控制每一行的数据
    for j in range(1, i + 1):
        # 在内层输出每一行的内容
        print(f"{
      
      j}*{
      
      i}={
      
      j * i}\t", end='')

    # 外层输出一个回车符号
    print()

operation result:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44996886/article/details/132418826