#Python 2 - 113 bytes#
def a(s):s=s[1:]or'0';l=len(s);return'#'+((l<5)*(s[-1]*(l==4)).join(i+(l==3)*i for i in s*6)or(6/l*s+s[-1]))[:6]
#Python 2 - 113 bytes#
def a(s):s=s[1:]or'0';l=len(s);return'#'+((l<5)*(s[-1]*(l==4)).join(i+(l==3)*i for i in s*6)or(6/l*s+s[-1]))[:6]