How can I write a simple callback function?
How can I write a simple callback function? Question: I have this example code, trying to demonstrate using a callback function: def callback(a, b): print(‘Sum = {0}’.format(a+b)) def main(callback=None): print(‘Add any two digits.’) if callback != None: callback main(callback(1, 2)) I get this result: Sum = 3 Add any two digits. It seems that the …