Untitled
import random def draw(height=10): max_width = 2 * height - 1 for i in range(height): layer = '*' * (2 * i + 1) centered_layer = layer.center(max_width) decorated_layer = ''.join( char if char == ' ' or random.random() > 0.25 else random.choice('O@') for char in centered_layer ) print(decorated_layer) trunk_width = max(1, (height // 8) * 2 + 1) trunk_height = height // 3 trunk = '|' * trunk_width for _ in range(trunk_height): print(trunk.center(max_width)) print('2 0 2 5'.center(max_width)) draw()
Leave a Comment