Quick actions

cmd+k|ctrl+k

Navigation

Languages

loops

Snippet info

Language

Python

Visibility

public

Author

briankiptoo

Created

2025-12-09T23:45:35.424717Z

Updated

2025-12-28T18:02:27.507119Z

def christmas_tree(height):
    for i in range(height):
        print(("*" * (i * 2 + 1)).center(height * 2 - 1))
    
    # Tree Trunk
    for _ in range(height // 3):
        # Print trunk (centered, width of 3 stars, can be adjusted)
        print(("|" * 3).center(height * 2 - 1))

# Set the desired height of the tree (e.g., 5 levels)
christmas_tree(5)
INFO