Python Forum
print 3 table in a 3*3 matrix format - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: print 3 table in a 3*3 matrix format (/thread-1449.html)



print 3 table in a 3*3 matrix format - MeeranRizvi - Jan-04-2017

Hello guys,

Here i have to print 3 table in 3*3 matrix format
x=3
for i in range(1,10):
    print(x*i)
it gives me the output of 3 table upto 9.
But how to print these values in a 3*3 matrix format?


RE: print 3 table in a 3*3 matrix format - Larz60+ - Jan-04-2017

you can use mod operator and 3 '% 3'
when result is 0, you want a line feed
add ', end='' where you don't want a line feed


RE: print 3 table in a 3*3 matrix format - sparkz_alot - Jan-04-2017

You might also want to check out this tutorial:

https://docs.python.org/3/tutorial/inputoutput.html#fancier-output-formatting