# [Python 2], 110 bytes <!-- language-all: lang-python --> def a(s):s=s[1:]or'0';l=len(s);return'#'+((l<5)*(s[-1]*(l>3)).join(i+(l==3)*i for i in s*6)+(6/l*s+s[-1]))[:6] [Try it online!][TIO-jxeotk8q] [Python 2]: https://docs.python.org/2/ [TIO-jxeotk8q]: https://tio.run/##XcuxDoIwFIXh3adoYOi9bVQKSghYX4QwFIVY07SkxcGnr@hiIGf6v@RM7/nhbB7jfRiJgoB1kKEVdec8zWhjpBnsoo0f5pe3NKUcwFzOyCC0e9ExMNcC8fB02oLmYKQskGkyOk800ZYEViKH8mhY4L8HYluXXZy8tjMoSNIEcfev0zqVWLeo1AbyIttcVN/f1jRW3y0W0w8 "Python 2 – Try It Online"