jweinst1
10/14/2015 - 10:43 PM

different string shapes for drawing in python

different string shapes for drawing in python

def strsquare(char, wid):
    row = ''.join([char for elem in range(wid)]) + '\n'
    shape = ''.join([row for elem in range(wid)])
    return shape
    
def printsquare(char, wid):
    print(strsquare(char, wid))
    
def strtriangle(char, wid):
    shape = ''
    count = 0
    while count < wid:
        shape += ''.join([char for elem in range(count)]) + '\n'
        count += 1
    return shape
    
def downwardtriangle(char, wid):
    shape = ''
    count = wid
    while count > 0:
        shape += ''.join([char for elem in range(count)]) + '\n'
        count -= 1
    return shape