def d2b(n):
    '''Returns the base 2 value of non-negative int n (base 10) as a list'''
    binStr= ''
    if n < 0: raise ValueError("number must be non-negative")
    if n == 0: return '0'
    while n > 0: binStr = str(n%2)+binStr; n = n>>1
    return list(binStr)
Returns the base 2 value of non-negative int n (base 10) as a list
recipes/Python/577657_Perpetual_calendar/recipe-577657.py