I already tried converting it to a string, adding 0
to it, but it still only shows me the decimal value, how can I make it show me its binary value?
If I try this:
binary = 0b010
print(binary)
or this:
binary = 0b010
print(str(binary))
which outputs this:
2
I also tried this:
binary = 0b010
print("{0:b}".format(binary))
which outputs this:
10
Desired output:
010
The bad part is that it does not fill in the number of 0 on the left, it gives me an output of 10
when I want 010
, but I want it to show the number of 0 possible for any binary that I put.
I'm new to Python, but every time I look for how to do it, it only appears to me as converting from integer to binary and showing it. But I can't use the bin()
function, so I resorted to asking it here directly, thanks for your understanding.