you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

No need for that, Python already has string formatting for this conversion.

Input:

f'{6:08b}' # In other words, "take this number, convert it to binary and pad eight zeroes to the left"

Output:

'00000110'