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?

matcha latte
  • 185
  • 1
  • 12

1 Answers1

0
answer = format(a,'b').zfill(len)
zondo
  • 19,901
  • 8
  • 44
  • 83
matcha latte
  • 185
  • 1
  • 12