def dec2bcd(num): new = '' for i in str(num): bNum= bin(int(i)).replace('0b','').zfill(4) new= new + bNum return new