creating a 3x3 multiplication table - 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: creating a 3x3 multiplication table (/thread-11009.html) |
creating a 3x3 multiplication table - aditvaddi - Jun-18-2018 So im trying to get this as the output: Here's the code i'm using:print(''' 1 2 3''',end="") for i in range(1,4): if i==1: print("") print('{:>1}|'.format(i),end="") for j in range(1,4): print('{:>2}'.format(i*j))My issue is that after each loop in i runs, the output of i*jprints in the next line, so you get the output as: I'm new to python. please help
RE: creating a 3x3 multiplication table - volcano63 - Jun-18-2018 You are missing end="" in that lineprint('{:>2}'.format(i*j))BTW, for empty line, just use print()
|