0

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?

Chauncey
  • 163
  • 11

1 Answers1

0
answer = format(a,'b').zfill(len)
zondo
  • 19,040
  • 7
  • 42
  • 82
Chauncey
  • 163
  • 11