def draw_cube(width, height):
    cube = [([' '] * width) for row in range(height)]
vertices = {'tc': (width // 2, 0), 'tl': (0, int(0.25 * height)), 'tr': (
    width - 1, int(0.25 * height)), 'cc': (width // 2, int(0.5 * height)),
    'bl': (0, int(0.75 * height)), 'br': (width - 1, int(0.75 * height)),
    'bc': (width // 2, height - 1)}
edges = ('tc', 'tl'), ('tc', 'tr'), ('tl', 'cc'), ('tl', 'bl'), ('tr', 'cc'), (
    'tr', 'br'), ('bl', 'bc'), ('br', 'bc'), ('cc', 'bc')
for edge in edges:
    v1 = vertices[edge[0]]
v2 = vertices[edge[1]]
x1 = v1[0]
y1 = v1[1]
x2 = v2[0]
y2 = v2[1]
if x1 > x2:
    x1, x2 = x2, x1
y1, y2 = y2, y1
try:
    m = (y2 - y1) / (x2 - x1)
except ZeroDivisionError:
    c = '|'
for yy in range(min(y1, y2), max(y1, y2)):
    cube[yy][x1] = c
else:
    c = '.'
yy = y1
for xx in range(x1, x2):
    cube[int(yy)][xx] = c
yy += m
cube_str = '\n'.join(''.join(row) for row in cube)
return cube_str
x = draw_cube(40, 20)
print(x)
Изометрический куб ascii с питоном