Skip to content

Instantly share code, notes, and snippets.

@Qiamast
Last active February 5, 2023 12:30
Show Gist options
  • Save Qiamast/ff477f457ba4454b7c1c6742c195f2f8 to your computer and use it in GitHub Desktop.
Save Qiamast/ff477f457ba4454b7c1c6742c195f2f8 to your computer and use it in GitHub Desktop.
Generate ASCII art without any packages
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