Q:

Binary shift on string in Python

Given a binary string, shift it by the amount given.
I am having trouble understanding why this code fails, I convert the string into binary then perform the shift, but I get unsupported operand type(s) for <<: 'str' and 'int'.
I think I am converting the binary string incorrectly but am not sure how else to do it.

def insertt(num, numb, shift):

  num = bin(int(num, 2) << shift)
  numb = bin(int(numb))
  print(bin(int(num, 2) | bin(int(numb, 2))

a = '10000000000'
b = '1001'
c = 2
insertt(a, b, c)

Expected result is just the shift. 
Thank you

A:

you have to shift your  binary string  before using bin : 
def insertt(num, shift):

  num = bin(int(num, 2) << shift)
  print(num)

a = '10000000000'
c = 2
insertt(a, c)

# output: 0b1000000000000

