0

all.

I want to change 1 to 0 and 0 to 1 in binary.

for example,

if binary is 00000110. I want to change it to 11111001.

how to do that in python3?

Best regards.

박형렬
  • 377
  • 1
  • 9
  • 24

1 Answers1

0

You can use the ~ operator. If A = 00100, ~A = 11011. If A is a string version of a decimal, convert it into int first.

Harshith Thota
  • 856
  • 8
  • 20