Good day! Please help me understand, I have a function:
def bin(n): if n == 0: return [] n, d = divmod(n, 2) return bin(n) + [d]
it returns the binary format of the number (peculiar), further:
n = input('int:') if n: try: n = int(n) except ValueError as err: print 'Error n' else: print 'n!' print bin(n)
I need, when n is entered, if it is an object that is not converted to an integer, then process this error and display the message until the error is processed and I do not understand why. And how can I put all this code into one function? Thanks in advance for your help.