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?

29th Jul 2025, 10:50 PM
SAIFULLAHI KHAMISU
SAIFULLAHI KHAMISU - avatar
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)))
30th Jul 2025, 12:20 AM
BroFar
BroFar - avatar
+ 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).
29th Jul 2025, 11:10 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar