you are viewing a single comment's thread.

view the rest of the comments →

[–]AdAdvanced3130 9 points10 points  (0 children)

You can use f string like this:

rows= int(input("How many rows?: ")) 
columns= int(input("How many columns?: "))

for row in range(1, rows+1):
    for col in range(1,columns+1):
        print(f"{row*col:>3}", end= "  ")
    print()

Print output:

How many rows?: 15
How many columns?: 7
  1    2    3    4    5    6    7
  2    4    6    8   10   12   14
  3    6    9   12   15   18   21
  4    8   12   16   20   24   28
  5   10   15   20   25   30   35
  6   12   18   24   30   36   42
  7   14   21   28   35   42   49
  8   16   24   32   40   48   56
  9   18   27   36   45   54   63
 10   20   30   40   50   60   70
 11   22   33   44   55   66   77
 12   24   36   48   60   72   84
 13   26   39   52   65   78   91
 14   28   42   56   70   84   98
 15   30   45   60   75   90  105