Created
March 19, 2021 20:57
-
-
Save Airbus5717/5ea35ebf6d497146c860ccb6f7ad4a7d to your computer and use it in GitHub Desktop.
ZipCodeCrap
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
convertDigits = [ | |
['|', '|', ':', ':', ':'], #0 | |
[':', ':', ':', '|', '|'], #1 | |
[':', ':', '|', ':', '|'], #2 | |
[':', ':', '|', '|', ':'], #3 | |
[':', '|', ':', ':', '|'], #4 | |
[':', '|', ':', '|', ':'], #5 | |
[':', '|', '|', ':', ':'], #6 | |
['|', ':', ':', ':', '|'], #7 | |
['|', ':', ':', '|', ':'], #8 | |
['|', ':', '|', ':', ':'] #9 | |
] | |
inputDigits = input("Enter 5 digits: ") | |
inputDigits = int(inputDigits) | |
if len(str(inputDigits)) != 5: | |
print("Wrong input") | |
quit() | |
else: | |
print('input digits are:', inputDigits) | |
print() | |
def digitSeperate(digit): | |
digitArray = [] | |
for i in str(digit): | |
digitArray.append(int(i)) | |
sumDigits = sum(digitArray) | |
#print(sumDigits) | |
return 20 - sumDigits | |
def printDigit(d): | |
print(d, end='') | |
def printBarCode(digit): | |
digit = str(digit) | |
zipCodefinal = [] | |
tmp = [] | |
i = 0 | |
while i < 5: | |
j = 0 | |
while j < 10: | |
if digit[i] == str(j): | |
zipCodefinal.append(convertDigits[j]) | |
j += 1 | |
i += 1 | |
zipCodefinal.append(convertDigits[digitSeperate(digit)]) | |
printDigit('|') | |
k_tmp = 0 | |
while k_tmp < 6: | |
print(''.join(zipCodefinal[k_tmp]), end='') | |
k_tmp += 1 | |
printDigit('|') | |
print('\n') | |
printBarCode(inputDigits) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment