Skip to content

Instantly share code, notes, and snippets.

@anhhoangta
Created August 20, 2015 02:52
Show Gist options
  • Save anhhoangta/9661114f5f9d12685663 to your computer and use it in GitHub Desktop.
Save anhhoangta/9661114f5f9d12685663 to your computer and use it in GitHub Desktop.
Nested For Loop
__author__ = 'anhhoangta'
#print the title of program
print("\r")
print("Mutiplication Table".center(38))
#print the first two lines
print("{:4}".format(""),end="")
for num in range(1,10):
print("{:2d}" .format(num), end="\t") #the first line
print()
print("-"*38) #the 2nd line
#print remanning lines use nested for loop
for i in range(1,10):
print("{:d}|".format(i),end="\t") #print the first column
for j in range(1, 10):
print("{:2d}" .format(i*j),end="\t") #print ixj with margin-right
print()
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment