Skip to content

Commit 5bebfb9

Browse files
committed
Contributing my Python project by the name of Bitmap Message in this repository.
1 parent 4d90840 commit 5bebfb9

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

BitMap-Message/bitmapmessage.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import sys
2+
3+
# (!) Try changing this multiline string to any image you like:
4+
5+
# There are 68 periods along the top and bottom of this string:
6+
# (You can also copy and paste this string from
7+
# https://inventwithpython.com/bitmapworld.txt)
8+
bitmap = """
9+
....................................................................
10+
************** * *** ** * ******************************
11+
********************* ** ** * * ****************************** *
12+
** ***************** ******************************
13+
************* ** * **** ** ************** *
14+
********* ******* **************** * *
15+
******** *************************** *
16+
* * **** *** *************** ****** ** *
17+
**** * *************** *** *** *
18+
****** ************* ** ** *
19+
******** ************* * ** ***
20+
******** ******** * *** ****
21+
********* ****** * **** ** * **
22+
********* ****** * * *** * *
23+
****** ***** ** ***** *
24+
***** **** * ********
25+
***** **** *********
26+
**** ** ******* *
27+
*** * *
28+
** * *
29+
...................................................................."""
30+
31+
print('Bitmap Message')
32+
print('Enter the message to display with the bitmap.')
33+
message = input('> ')
34+
if message == '':
35+
sys.exit()
36+
37+
# Loop over each line in the bitmap:
38+
for line in bitmap.splitlines():
39+
# Loop over each character in the line:
40+
for i, bit in enumerate(line):
41+
if bit == ' ':
42+
# Print an empty space since there's a space in the bitmap:
43+
print(' ', end='')
44+
else:
45+
# Print a character from the message:
46+
print(message[i % len(message)], end='')
47+
print() # Print a newline.

0 commit comments

Comments
 (0)