def printTriangle(size):
    mid = size >> 1;
    levels = (size + 1) >> 1
    space = ' '
    dot = '*'
    for level in range(levels):
        left = mid - level;
        right = mid + level;
        levelRes = ''
        for index in range(size):
            if index < left:
                levelRes = levelRes + space
            elif index <= right:
                levelRes = levelRes + dot
        print levelRes

def printTriangle2(size):
    for level in range(size):
        print ' '*(size-level -1) + '*'*(2*level+1)

printTriangle2(5)

51f0899519b36c02501d2ea5946e707d7d6f977a
def printTriangle(size):
    mid = size >> 1;
    levels = (size + 1) >> 1
    space = ' '
    dot = '*'
    for level in range(levels):
        left = mid - level;
        right = mid + level;
        levelRes = ''
        for index in range(size):
            if index < left:
                levelRes = levelRes + space
            elif index <= right:
                levelRes = levelRes + dot
        print levelRes

def printTriangle2(size):
    for level in range(size):
        print ' '*(size-level -1) + '*'*(2*level+1)

printTriangle2(5)
