Home > database >  Multiplication table with for loops
Multiplication table with for loops

Time:09-25

I've been trying to make a multiplication table with for loops in Python.


for i in range(1,11):
    print("\t", i)
print("\n")
print("-------------------------------")
for a in range(1, 11):
    print(a)
    for t in range(1,11):
        print("\t", a * t, end="\t")

The problem I have is the output puts every vertical factor on the wrong side of the products, and I would like to have them like 1 is.

This is a picture of what I mean:

Any solutions? I've been trying and trying to move the \t and \n in other places to make it work but it never seems to work for me to get them the way I want.

Thanks in advance.

CodePudding user response:

#                    
  • Related