Search code examples
pythonpython-3.xbinarydecimalconverters

I'm trying to program a decimal number into binary


import numbers


nummer = int(input("Enter a number:"))
number=()
while nummer == 0: 
    number(nummer)

binary_numbers = format(nummer, "b")

print(binary_numbers)
    
nummer=0

output when entering the number 32 is:

100000

but I want the rest to be filled with 0 like this:

00100000

and i don`t know how


Solution

  • Just try:

    format(nummer, "08b")