2

I'm trying to convert numbers into binary strings with a specified length in python. In my function, the length N is a variable, so I tried f'{3:Nb}', where 3 is just some random numbers. However, it returns ValueError: Invalid format specifier. Is there a way I can include the variable in this string formatting mini-language? Thanks!

ZR-
  • 809
  • 1
  • 4
  • 12

0 Answers0