Really new to python and maybe I am just missing something that is quite easy. I am trying out a simple recursive function that you would assign to a freshman CS class and I am trying to do in in Python in an attempt to learn the language. I can't seem to get this correct, it prints the correct digits but I am trying to return a string but I keep having issues. I have tried declaring result inside the function, but then it gets cleared out on every pass. I have tried passing in a variable along with the integer, but it too clears itself out with each iteration. Any point in the right direction would be great. Thanks.
def binaryRepresentation(m) : if m == 0: return else: if m > 0: result = (m % 2) binaryRepresentation(m/2) # print result return result numberInputted = int(raw_input("Enter a number to be converted: ")) print binaryRepresentation(numberInputted)