I need to change a zip code into a series of dots and dashes (a barcode), but I can't figure out how

Posted by Maggie on Stack Overflow See other posts from Stack Overflow or by Maggie
Published on 2010-05-09T18:55:54Z Indexed on 2010/05/09 19:08 UTC
Read the original article Hit count: 188

Filed under:

Here's what I've got so far:

def encodeFive(zip):

zero =  "||:::"

one =   ":::||"

two =   "::|:|"

three = "::||:"

four =  ":|::|"

five =  ":|:|:"

six =   ":||::"

seven = "|:::|"

eight = "|::|:"

nine =  "|:|::"

codeList = [zero,one,two,three,four,five,six,seven,eight,nine]

allCodes = zero+one+two+three+four+five+six+seven+eight+nine

code = ""
digits = str(zip)
for i in digits:

    code = code + i    

return code

With this I'll get the original zip code in a string, but none of the numbers are encoded into the barcode. I've figured out how to encode one number, but it wont work the same way with five numbers.

© Stack Overflow or respective owner

Related posts about python