#!/usr/bin/env python3
# nested for loops

outerL = int( input('Outer loop lower? ') )
outerU = int( input('Outer loop upper? ') )
outerS = int( input('Outer step size? ') )
inner = int( input('Inner loop? ') )
innerS = 5

# Column headers:
print('  : ', end='')
for col in range(0, inner, innerS):
    print('%6i ' % (col), end='')
print()
print('--: ', end='')
for col in range(0, inner, innerS):
    print('------ ', end='')
print()

# The table itself
for row in range(outerL, outerU, outerS):
    
    # Row header:
    print('%2i: ' % (row), end='')

    for col in range(0, inner, innerS):
        print('%6i ' % (row*col),  end='')
    print()