Q:

Python user input for def function

How to do a number input by user first then only display the answer?
a = int(raw_input("Enter number: "),twoscomp)

def tobin(x, count = 8):
    return "".join(map(lambda y:str((x>>y)&1), range(count-1, -1, -1)))

def twoscomp(bin_str):
    return tobin(-int(bin_str,2),len(bin_str))

print a

A:

I believe this is what you're trying to do?
def tobin(x, count = 8):
    return "".join(map(lambda y:str((x>>y)&1), range(count-1, -1, -1)))

def twoscomp(bin_str):
    return tobin(-int(bin_str,2),len(bin_str))

a = twoscomp(raw_input("Enter number: "))

print a

Things to note: 

You need to define things before you use them, and that includes functions. 
Indentation is important, and you should use it.

