0
How do I print a multiplication table neatly?
I want to print a multiplication table from 1 to 5 so it looks like this: 1 x 1 = 1 1 x 2 = 2 ... 5 x 5 = 25 Whatâs the simplest way to do that with loops?
2 Answers
+ 2
Aleksei Radchenkov provided the basis for a oneliner
print('\n'.join(f"{a} x {b} = {a * b}" for a in range(1, 6) for b in range(1, 6)))
+ 1
Once again, please provide an example of your attempt.
The idea though is to use nested loops (one for a and one for b in a x b = c).