Last active
February 5, 2023 12:30
-
-
Save Qiamast/ff477f457ba4454b7c1c6742c195f2f8 to your computer and use it in GitHub Desktop.
Generate ASCII art without any packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ascii_art(text): | |
characters = [' ', '.', '*', ':', 'o', '&', '8', '#', '@'] | |
output = '' | |
for char in text: | |
index = ord(char) % len(characters) | |
output += characters[index] + ' ' | |
return output | |
print(ascii_art('Hello World!')) | |
""" | |
This code maps each character in the input text to a character in the characters list, | |
based on the ASCII value of the character. The resulting ASCII art is built up from these characters. | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment