I have a new python learner, I want to ask a question about string format.
a = 3
len = 5
I want to format a as a binary number and the number length is 5. So I want to format it to '00011'.
How can I do in python?
I have a new python learner, I want to ask a question about string format.
a = 3
len = 5
I want to format a as a binary number and the number length is 5. So I want to format it to '00011'.
How can I do in python?
answer = format(a,'b').zfill(len)