0
def add_binary(a,b):
    return bin(a+b)[2:]

Why is "[2:]" used here?

1 Answers1

0

convert number into it's binary and remove first two characters 0b.

Example:
Original number: 10
Binary string: 0b1010

after that it will be 1010 only.

Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51