terminal_message.py

A cute animation to send your friends/S.O. Can be executed from terminal. Written in python.
mail@pastecode.io avatar
unknown
python
a year ago
864 B
16
Indexable
Never
import time
import os

def display_heart():
    heart = [
        "  *****     *****  ",
        " *******   ******* ",
        " *******   ******* ",
        " *******   ******* ",
        "  ***************  ",
        "   *************   ",
        "    ***********    ",
        "      *******      ",
        "        ***        ",
        "         *         "
    ]

    message = "You're loved!"

    for line in heart:
        print(line.center(40, ' ')) # Center the heart in the terminal
    print(message.center(40, ' '))

def main():
    while True:
        os.system('cls' if os.name == 'nt' else 'clear') # Clear screen
        display_heart()
        time.sleep(1) # Heart stays up on the terminal for 1 second

        os.system('cls' if os.name == 'nt' else 'clear') # Clear screen
        time.sleep(0.5)

if __name__ == "__main__":
    main()