Skip to content

Instantly share code, notes, and snippets.

@meganehouser
Created April 4, 2015 00:44
Show Gist options
  • Save meganehouser/179da869944c5f2a47eb to your computer and use it in GitHub Desktop.
Save meganehouser/179da869944c5f2a47eb to your computer and use it in GitHub Desktop.
Show LED numbers.
import os
led_nums = [
[" _ ", "| |", "|_|"],
[" ", " |", " |"],
[" _ ", " _|", "|_ "],
[" _ ", " _|", " _|"],
[" ", "|_|", " |"],
[" _ ", "|_ ", " _|"],
[" _ ", " _|", "|_|"],
[" _ ", " |", " |"],
[" _ ", "|_|", "|_|"],
[" _ ", "|_|", " |"]]
def to_led(num):
ns = [int(n) for n in num if n.isdigit()]
s = ""
for i in range(3):
for n in ns:
s += led_nums[n][i]
else:
s += os.linesep
return s
if __name__ == '__main__':
try:
while True:
num = input("input number: ")
led = to_led(num)
print(led)
except KeyboardInterrupt:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment