Muhammad Ali wrote:
def separateToList(num):
    """
    changes an integer into a list with 0's padded to the left if the number is 
in tens or units
    """
    assert(num <= 255)


    s = str(num)
    li = []
    if len(s) > 2:
        li = [s[0:1], s[1:2], s[2:3]]
    elif len(s) > 1:
        li = [0, s[0:1], s[1:2]]
    elif len(s) > 0:
        li = [0, 0, s[0:1]]

    return map(int, li)

return [int(v) for v in ("00" + str(num))[-3:]]


Albert
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to