// Sample solution to Lab 2

import string

def zip():
    table = ["||...", "...||", "..|.|", "..||.", ".|..|",
             ".|.|.", ".||..", "|...|", "|..|.", "|.|.."]

    zipcode = raw_input("Enter a zip code: ")

    # create a list of individual digits from the zip code
    numericDigits = []
    for digit in zipcode:
        numericDigits.append(int(digit))

    # encode each digit as a barcode
    encodedDigits = []
    for d in numericDigits:
        code = table[d]
        encodedDigits.append(code)

    # compute the correction digit by adding up all digits and
    # choosing the correction digit to make the sum a multiple of 10
    sum = 0
    for d in numericDigits:
        sum = sum + d
    correctionDigit = (10 - (sum % 10)) % 10

    # add the correction digit code to the end of encodedDigits
    code = table[correctionDigit]
    encodedDigits.append(code)

    # create the final barcode
    barcode = ""
    for code in encodedDigits:
        barcode = barcode + code

    # add endmarkers
    barcode = "|" + barcode + "|"

    print "The corresponding bar code is:"
    print barcode
    
