Merry Christmas Dev community. Here is a simple Christmas tree using Python.
# Christmas Tree in Python
for i in range(10):
print(''.join(['.'] * (9 - i) + ['^'] * (1 + i * 2) + ['.'] * (9 - i)))
else:
print(''.join(['-'] * 8 + ['| |'] + ['-'] * 8))
'''
.........^.........
........^^^........
.......^^^^^.......
......^^^^^^^......
.....^^^^^^^^^.....
....^^^^^^^^^^^....
...^^^^^^^^^^^^^...
..^^^^^^^^^^^^^^^..
.^^^^^^^^^^^^^^^^^.
^^^^^^^^^^^^^^^^^^^
--------| |--------
Merry Christmas to all of you. @shwetabh1
'''
There is no use of the else clause but I have used it deliberately, to expose it to devs who are yet not aware of it.
The else clause executes after the loop completes normally. It is useful in cases when we break from a loop. You can read more about it here.
lol I like that you added the else clause just so others can learn 🙌