🔒 Closed Python3: print integers as glyphs

Status
Not open for further replies.

nnivx

Enthusiast
Share ko lang yung ginawa ko a while ago para sa assignment ng kaibigan ko. This code will print positive integers as a 3-line glyph:
Code:
# Sample output for 5674:
#  _   _   _
# |_  |_    | |_|
#  _| |_|   |   |

s = input('Enter Number: ')
STAMP = ' _ |_||_|'
NUM   = ['4', '13467', '38', '36', '167', '56', '5', '3467', '', '6']

# data
buf = []
for nc in s:
    buf.append(''.join([STAMP[x] if (str(x) not in NUM[int(nc)]) else ' ' for x in range(0, 9)]))
   
# print per line
for x in range(0, 9, 3):
    print(' '.join([c[x:x+3] for c in buf]))


Disclaimer: this is just how I did it, not sure kung may mas ez pa. Kung meron kayong better code or other ideas, share niyo rin :>

Spoiler contents are visible only to Established Members.
 
Status
Not open for further replies.

About this Thread

  • 8
    Replies
  • 852
    Views
  • 6
    Participants
Last reply from:
ralph_acero

Trending Topics

Online now

Members online
862
Guests online
3,344
Total visitors
4,206

Forum statistics

Threads
2,305,942
Posts
29,168,691
Members
1,195,513
Latest member
miken0204
Back
Top