How to print the multiplication table of nine using Python?

You can use two loops to print the multiplication table of nine. Here is an example code:

for i in range(1, 10):
    for j in range(1, i+1):
        print(f"{j} * {i} = {j*i}", end="\t")
    print()

In this code, the outer loop controls the number of rows, and the inner loop controls the multiplication items in each row. Use the range() function to generate the necessary number sequence, and use the print() function to output each item of the multiplication table. After the inner loop ends, use the print() function to output a newline character to move to the next line.

bannerAds