I am trying to create a function and I keep on getting the same error message. And this is something that I have had a problem with for a while. The (key) input is supposed to be an integer. The same integer that's (x). Like input 200 for key/x and the output would be '11001000'. The error message I keep getting is:
"TypeError: 'int' object is not iterable"
I am trying to make it so that all of the numbers are integers. I am trying to make a function that executes the same thing that "{0:b}".format(200)
would deliver. So the code that I have come up with is:
def createBinKeyFromKey(key):
for x in key:
return "{o:b}".format(x)
I have also tried to use while loop to execute it correctly and not get an error message, but that hasn't worked so far.
I would like to call an integer. As in the place where it says (key), the input there would be an integer. And then it would return the binary string of the integer. For example I would input createBinKeyFromKey(200) in python shell and it would return '11001000'